diff --git a/pkg/dockerutil/dockerutils.go b/pkg/dockerutil/dockerutils.go index fa8d919cdc3..a3d6138092f 100644 --- a/pkg/dockerutil/dockerutils.go +++ b/pkg/dockerutil/dockerutils.go @@ -664,7 +664,12 @@ func ComposeCmd(cmd *ComposeCmdOpts) (string, string, error) { go func() { for inOut.Scan() { - chanOut <- inOut.Bytes() + // Bytes() underlying array may be overwritten by the next call to Scan(). + // Copy it to a new allocation to prevent corruption. + token := inOut.Bytes() + duplicate := make([]byte, len(token)) + copy(duplicate, token) + chanOut <- duplicate } close(stopOut) }()