1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #2823 from dotcloud/2817-run_rm-fix

Fix docker run -rm
This commit is contained in:
Michael Crosby 2013-11-22 11:35:29 -08:00
commit ae8c589d35

View file

@ -2123,21 +2123,24 @@ func (cli *DockerCli) CmdRun(args ...string) error {
// Detached mode // Detached mode
<-wait <-wait
} else { } else {
running, status, err := getExitCode(cli, runResult.ID) var status int
if err != nil {
return err
}
if autoRemove { 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 { if _, _, err := cli.call("POST", "/containers/"+runResult.ID+"/wait", nil); err != nil {
return err return err
} }
_, status, err = getExitCode(cli, runResult.ID)
if err != nil {
return err
}
if _, _, err := cli.call("DELETE", "/containers/"+runResult.ID, nil); err != nil { if _, _, err := cli.call("DELETE", "/containers/"+runResult.ID, nil); err != nil {
return err return err
} }
} else {
_, status, err = getExitCode(cli, runResult.ID)
if err != nil {
return err
}
} }
if status != 0 { if status != 0 {
return &utils.StatusError{Status: status} return &utils.StatusError{Status: status}