Merge pull request #22777 from WeiZhang555/wait-restarting
Bug fix: `docker run -i --restart always` hangs Upstream-commit: 4dafd107ad0cb89e1a7f9e3bcc66fb6a5a5c99c5 Component: engine
This commit is contained in:
@ -119,6 +119,15 @@ func (daemon *Daemon) containerAttach(c *container.Container, stdin io.ReadClose
|
||||
}()
|
||||
stdinPipe = r
|
||||
}
|
||||
|
||||
waitChan := make(chan struct{})
|
||||
if c.Config.StdinOnce && !c.Config.Tty {
|
||||
go func() {
|
||||
c.WaitStop(-1 * time.Second)
|
||||
close(waitChan)
|
||||
}()
|
||||
}
|
||||
|
||||
err := <-c.Attach(stdinPipe, stdout, stderr, keys)
|
||||
if err != nil {
|
||||
if _, ok := err.(container.DetachError); ok {
|
||||
@ -131,7 +140,7 @@ func (daemon *Daemon) containerAttach(c *container.Container, stdin io.ReadClose
|
||||
// If we are in stdinonce mode, wait for the process to end
|
||||
// otherwise, simply return
|
||||
if c.Config.StdinOnce && !c.Config.Tty {
|
||||
c.WaitStop(-1 * time.Second)
|
||||
<-waitChan
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user