|
@@ -28,15 +28,8 @@ func (cli *DockerCli) CmdRm(args ...string) error {
|
|
|
}
|
|
|
name = strings.Trim(name, "/")
|
|
|
|
|
|
- options := types.ContainerRemoveOptions{
|
|
|
- ContainerID: name,
|
|
|
- RemoveVolumes: *v,
|
|
|
- RemoveLinks: *link,
|
|
|
- Force: *force,
|
|
|
- }
|
|
|
-
|
|
|
- if err := cli.client.ContainerRemove(options); err != nil {
|
|
|
- errs = append(errs, fmt.Sprintf("Failed to remove container (%s): %s", name, err))
|
|
|
+ if err := cli.removeContainer(name, *v, *link, *force); err != nil {
|
|
|
+ errs = append(errs, err.Error())
|
|
|
} else {
|
|
|
fmt.Fprintf(cli.out, "%s\n", name)
|
|
|
}
|
|
@@ -46,3 +39,16 @@ func (cli *DockerCli) CmdRm(args ...string) error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func (cli *DockerCli) removeContainer(containerID string, removeVolumes, removeLinks, force bool) error {
|
|
|
+ options := types.ContainerRemoveOptions{
|
|
|
+ ContainerID: containerID,
|
|
|
+ RemoveVolumes: removeVolumes,
|
|
|
+ RemoveLinks: removeLinks,
|
|
|
+ Force: force,
|
|
|
+ }
|
|
|
+ if err := cli.client.ContainerRemove(options); err != nil {
|
|
|
+ return fmt.Errorf("Failed to remove container (%s): %v", containerID, err)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|