mirror of https://github.com/docker/docs.git
Merge pull request #8871 from tonistiigi/start-wait-hijack
Wait for hijack on docker start command
This commit is contained in:
commit
a34f31b488
|
@ -627,6 +627,8 @@ func (cli *DockerCli) CmdStart(args ...string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hijacked := make(chan io.Closer)
|
||||||
|
|
||||||
if *attach || *openStdin {
|
if *attach || *openStdin {
|
||||||
if cmd.NArg() > 1 {
|
if cmd.NArg() > 1 {
|
||||||
return fmt.Errorf("You cannot start and attach multiple containers at once.")
|
return fmt.Errorf("You cannot start and attach multiple containers at once.")
|
||||||
|
@ -663,8 +665,24 @@ func (cli *DockerCli) CmdStart(args ...string) error {
|
||||||
v.Set("stderr", "1")
|
v.Set("stderr", "1")
|
||||||
|
|
||||||
cErr = promise.Go(func() error {
|
cErr = promise.Go(func() error {
|
||||||
return cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), tty, in, cli.out, cli.err, nil, nil)
|
return cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), tty, in, cli.out, cli.err, hijacked, nil)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
close(hijacked)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acknowledge the hijack before starting
|
||||||
|
select {
|
||||||
|
case closer := <-hijacked:
|
||||||
|
// Make sure that the hijack gets closed when returning (results
|
||||||
|
// in closing the hijack chan and freeing server's goroutines)
|
||||||
|
if closer != nil {
|
||||||
|
defer closer.Close()
|
||||||
|
}
|
||||||
|
case err := <-cErr:
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var encounteredError error
|
var encounteredError error
|
||||||
|
|
Loading…
Reference in New Issue