From 8a9167da82b3824272fdbfcc25b3671cd1260e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Brauer?= Date: Tue, 25 May 2021 14:35:52 +0200 Subject: [PATCH] fix: avoid race condition by not running exec/start twice (#702) ContainerExecAttach implicitly runs ContainerExecStart while attaching to stdout/stderr. Ref: https://github.com/moby/moby/blob/e02bc91dcbf6ab70ab39352f3577a4394b0f863a/client/container_exec.go#L40 Calling both can lead to a race condition as observed in #627 Fixes: #627 Co-authored-by: Markus Wolf Co-authored-by: Markus Wolf --- pkg/container/docker_run.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go index 2670469..87f9f11 100644 --- a/pkg/container/docker_run.go +++ b/pkg/container/docker_run.go @@ -456,13 +456,6 @@ func (cr *containerReference) exec(cmd []string, env map[string]string, user str errWriter = os.Stderr } - err = cr.cli.ContainerExecStart(ctx, idResp.ID, types.ExecStartCheck{ - Tty: isTerminal, - }) - if err != nil { - return errors.WithStack(err) - } - if !isTerminal || os.Getenv("NORAW") != "" { _, err = stdcopy.StdCopy(outWriter, errWriter, resp.Reader) } else {