@@ -28,15 +28,8 @@ func (cli *DockerCli) CmdRm(args ...string) error {
2828 }
2929 name = strings .Trim (name , "/" )
3030
31- options := types.ContainerRemoveOptions {
32- ContainerID : name ,
33- RemoveVolumes : * v ,
34- RemoveLinks : * link ,
35- Force : * force ,
36- }
37-
38- if err := cli .client .ContainerRemove (options ); err != nil {
39- errs = append (errs , fmt .Sprintf ("Failed to remove container (%s): %s" , name , err ))
31+ if err := cli .removeContainer (name , * v , * link , * force ); err != nil {
32+ errs = append (errs , err .Error ())
4033 } else {
4134 fmt .Fprintf (cli .out , "%s\n " , name )
4235 }
@@ -46,3 +39,16 @@ func (cli *DockerCli) CmdRm(args ...string) error {
4639 }
4740 return nil
4841}
42+
43+ func (cli * DockerCli ) removeContainer (containerID string , removeVolumes , removeLinks , force bool ) error {
44+ options := types.ContainerRemoveOptions {
45+ ContainerID : containerID ,
46+ RemoveVolumes : removeVolumes ,
47+ RemoveLinks : removeLinks ,
48+ Force : force ,
49+ }
50+ if err := cli .client .ContainerRemove (options ); err != nil {
51+ return fmt .Errorf ("Failed to remove container (%s): %v" , containerID , err )
52+ }
53+ return nil
54+ }
0 commit comments