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:
commit
ae8c589d35
1 changed files with 11 additions and 8 deletions
19
commands.go
19
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}
|
||||
|
|
Loading…
Reference in a new issue