Stop/Kill options for containers removal

Docker-DCO-1.1-Signed-off-by: Adrien Folie <folie.adrien@gmail.com> (github: folieadrien)
This commit is contained in:
Adrien Folie
2014-07-11 23:26:08 +00:00
committed by Victor Vieux
parent d53db040c8
commit 7810070630
3 changed files with 29 additions and 7 deletions
+10 -3
View File
@@ -983,7 +983,8 @@ func (cli *DockerCli) CmdRm(args ...string) error {
cmd := cli.Subcmd("rm", "[OPTIONS] CONTAINER [CONTAINER...]", "Remove one or more containers")
v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container")
link := cmd.Bool([]string{"l", "#link", "-link"}, false, "Remove the specified link and not the underlying container")
force := cmd.Bool([]string{"f", "-force"}, false, "Force removal of running container")
stop := cmd.Bool([]string{"#f", "s", "#-force", "-stop"}, false, "Stop and remove a running container")
kill := cmd.Bool([]string{"k", "-kill"}, false, "Kill and remove a running container")
if err := cmd.Parse(args); err != nil {
return nil
@@ -992,6 +993,9 @@ func (cli *DockerCli) CmdRm(args ...string) error {
cmd.Usage()
return nil
}
if *stop && *kill {
return fmt.Errorf("Conflicting options: -s/--stop and -k/--kill")
}
val := url.Values{}
if *v {
val.Set("v", "1")
@@ -999,8 +1003,11 @@ func (cli *DockerCli) CmdRm(args ...string) error {
if *link {
val.Set("link", "1")
}
if *force {
val.Set("force", "1")
if *stop {
val.Set("stop", "1")
}
if *kill {
val.Set("kill", "1")
}
var encounteredError error