... | ... |
@@ -1433,6 +1433,9 @@ func (cli *DockerCli) CmdRun(args ...string) error { |
1433 | 1433 |
return nil |
1434 | 1434 |
} |
1435 | 1435 |
|
1436 |
+ flRm := cmd.Lookup("rm") |
|
1437 |
+ autoRemove, _ := strconv.ParseBool(flRm.Value.String()) |
|
1438 |
+ |
|
1436 | 1439 |
var containerIDFile *os.File |
1437 | 1440 |
if len(hostConfig.ContainerIDFile) > 0 { |
1438 | 1441 |
if _, err := ioutil.ReadFile(hostConfig.ContainerIDFile); err == nil { |
... | ... |
@@ -1580,6 +1583,12 @@ func (cli *DockerCli) CmdRun(args ...string) error { |
1580 | 1580 |
if err != nil { |
1581 | 1581 |
return err |
1582 | 1582 |
} |
1583 |
+ if autoRemove { |
|
1584 |
+ _, _, err = cli.call("DELETE", "/containers/"+runResult.ID, nil) |
|
1585 |
+ if err != nil { |
|
1586 |
+ return err |
|
1587 |
+ } |
|
1588 |
+ } |
|
1583 | 1589 |
if status != 0 { |
1584 | 1590 |
return &utils.StatusError{Status: status} |
1585 | 1591 |
} |
... | ... |
@@ -90,7 +90,6 @@ type HostConfig struct { |
90 | 90 |
Binds []string |
91 | 91 |
ContainerIDFile string |
92 | 92 |
LxcConf []KeyValuePair |
93 |
- AutoRemove bool |
|
94 | 93 |
} |
95 | 94 |
|
96 | 95 |
type BindMap struct { |
... | ... |
@@ -248,7 +247,6 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig, |
248 | 248 |
Binds: binds, |
249 | 249 |
ContainerIDFile: *flContainerIDFile, |
250 | 250 |
LxcConf: lxcConf, |
251 |
- AutoRemove: *flAutoRemove, |
|
252 | 251 |
} |
253 | 252 |
|
254 | 253 |
if capabilities != nil && *flMemory > 0 && !capabilities.SwapLimit { |
... | ... |
@@ -1027,11 +1025,6 @@ func (container *Container) monitor(hostConfig *HostConfig) { |
1027 | 1027 |
// FIXME: why are we serializing running state to disk in the first place? |
1028 | 1028 |
//log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err) |
1029 | 1029 |
} |
1030 |
- if hostConfig != nil { |
|
1031 |
- if hostConfig.AutoRemove { |
|
1032 |
- container.runtime.Destroy(container) |
|
1033 |
- } |
|
1034 |
- } |
|
1035 | 1030 |
} |
1036 | 1031 |
|
1037 | 1032 |
func (container *Container) kill() error { |