Skip to content

Commit

Permalink
fix: avoid race condition by not running exec/start twice
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ZauberNerd and KnisterPeter committed May 23, 2021
1 parent 764263c commit 56f7fab
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions pkg/container/docker_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,6 @@ func (cr *containerReference) exec(cmd []string, env map[string]string) common.E
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 {
Expand Down

0 comments on commit 56f7fab

Please sign in to comment.