Skip to content

Commit 446f36c

Browse files
committed
run: cleanup – move "detached" early exit earlier
Since everything else after the `apiClient.ContainerStart` block is under an `if attach` conditional, we can move the "detached" early exit up. Signed-off-by: Laura Brehm <[email protected]>
1 parent 8431298 commit 446f36c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cli/command/container/run.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,14 @@ func runContainer(ctx context.Context, dockerCli command.Cli, runOpts *runOption
215215
return toStatusError(err)
216216
}
217217

218-
if attach && config.Tty && dockerCli.Out().IsTerminal() {
218+
// Detached mode: wait for the id to be displayed and return.
219+
if !attach {
220+
// Detached mode
221+
<-waitDisplayID
222+
return nil
223+
}
224+
225+
if config.Tty && dockerCli.Out().IsTerminal() {
219226
if err := MonitorTtySize(ctx, dockerCli, containerID, false); err != nil {
220227
_, _ = fmt.Fprintln(stderr, "Error monitoring TTY size:", err)
221228
}
@@ -233,13 +240,6 @@ func runContainer(ctx context.Context, dockerCli command.Cli, runOpts *runOption
233240
}
234241
}
235242

236-
// Detached mode: wait for the id to be displayed and return.
237-
if !attach {
238-
// Detached mode
239-
<-waitDisplayID
240-
return nil
241-
}
242-
243243
status := <-statusChan
244244
if status != 0 {
245245
return cli.StatusError{StatusCode: status}

0 commit comments

Comments
 (0)