mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #2032 from dotcloud/move-rm-to-client
Move run -rm to the cli only
This commit is contained in:
commit
31fd11860b
2 changed files with 9 additions and 7 deletions
|
@ -1433,6 +1433,9 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flRm := cmd.Lookup("rm")
|
||||||
|
autoRemove, _ := strconv.ParseBool(flRm.Value.String())
|
||||||
|
|
||||||
var containerIDFile *os.File
|
var containerIDFile *os.File
|
||||||
if len(hostConfig.ContainerIDFile) > 0 {
|
if len(hostConfig.ContainerIDFile) > 0 {
|
||||||
if _, err := ioutil.ReadFile(hostConfig.ContainerIDFile); err == nil {
|
if _, err := ioutil.ReadFile(hostConfig.ContainerIDFile); err == nil {
|
||||||
|
@ -1580,6 +1583,12 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if autoRemove {
|
||||||
|
_, _, err = cli.call("DELETE", "/containers/"+runResult.ID, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
if status != 0 {
|
if status != 0 {
|
||||||
return &utils.StatusError{Status: status}
|
return &utils.StatusError{Status: status}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,6 @@ type HostConfig struct {
|
||||||
Binds []string
|
Binds []string
|
||||||
ContainerIDFile string
|
ContainerIDFile string
|
||||||
LxcConf []KeyValuePair
|
LxcConf []KeyValuePair
|
||||||
AutoRemove bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BindMap struct {
|
type BindMap struct {
|
||||||
|
@ -248,7 +247,6 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig,
|
||||||
Binds: binds,
|
Binds: binds,
|
||||||
ContainerIDFile: *flContainerIDFile,
|
ContainerIDFile: *flContainerIDFile,
|
||||||
LxcConf: lxcConf,
|
LxcConf: lxcConf,
|
||||||
AutoRemove: *flAutoRemove,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if capabilities != nil && *flMemory > 0 && !capabilities.SwapLimit {
|
if capabilities != nil && *flMemory > 0 && !capabilities.SwapLimit {
|
||||||
|
@ -1027,11 +1025,6 @@ func (container *Container) monitor(hostConfig *HostConfig) {
|
||||||
// FIXME: why are we serializing running state to disk in the first place?
|
// FIXME: why are we serializing running state to disk in the first place?
|
||||||
//log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err)
|
//log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err)
|
||||||
}
|
}
|
||||||
if hostConfig != nil {
|
|
||||||
if hostConfig.AutoRemove {
|
|
||||||
container.runtime.Destroy(container)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) kill() error {
|
func (container *Container) kill() error {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue