1
0
mirror of https://github.com/docker/cli.git synced 2026-01-16 20:22:36 +03:00

Make sure the ID is displayed usgin run -d

Upstream-commit: bd144a64f652895a41b67464a426839ef79d73dc
Component: engine
This commit is contained in:
Guillaume J. Charmes
2013-06-27 12:48:25 -07:00
parent 7b52085a24
commit 13ee8793a9

View File

@@ -1278,9 +1278,15 @@ func (cli *DockerCli) CmdRun(args ...string) error {
return err
}
var wait chan struct{}
if !config.AttachStdout && !config.AttachStderr {
// Make this asynchrone in order to let the client write to stdin before having to read the ID
go fmt.Fprintf(cli.out, "%s\n", runResult.ID)
wait = make(chan struct{})
go func() {
defer close(wait)
fmt.Fprintf(cli.out, "%s\n", runResult.ID)
}()
}
if config.AttachStdin || config.AttachStdout || config.AttachStderr {
@@ -1309,6 +1315,10 @@ func (cli *DockerCli) CmdRun(args ...string) error {
return err
}
}
if !config.AttachStdout && !config.AttachStderr {
<-wait
}
return nil
}