From 1e7c04fcfe0b1dbc93a8d70e7bf94e963aa764d8 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 22 Nov 2013 11:23:48 -0800 Subject: [PATCH] fix -rm --- commands.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/commands.go b/commands.go index c514aa28a0..d9759c2894 100644 --- a/commands.go +++ b/commands.go @@ -2123,21 +2123,24 @@ func (cli *DockerCli) CmdRun(args ...string) error { // Detached mode <-wait } else { - running, status, err := getExitCode(cli, runResult.ID) - if err != nil { - return err - } + var status int + if autoRemove { - if running { - return fmt.Errorf("Impossible to auto-remove a detached container") - } - // Wait for the process to if _, _, err := cli.call("POST", "/containers/"+runResult.ID+"/wait", nil); err != nil { return err } + _, status, err = getExitCode(cli, runResult.ID) + if err != nil { + return err + } if _, _, err := cli.call("DELETE", "/containers/"+runResult.ID, nil); err != nil { return err } + } else { + _, status, err = getExitCode(cli, runResult.ID) + if err != nil { + return err + } } if status != 0 { return &utils.StatusError{Status: status}