Forcibly remove container

Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
pull/6/head
Xianglin Gao 2017-04-11 19:18:56 +08:00
parent 9a0f5ccb33
commit 0144803c07
2 changed files with 2 additions and 3 deletions

View File

@ -287,7 +287,6 @@ func (ds *dockerService) StopContainer(containerID string, timeout int64) error
}
// RemoveContainer removes the container.
// TODO: If a container is still running, should we forcibly remove it?
func (ds *dockerService) RemoveContainer(containerID string) error {
// Ideally, log lifecycle should be independent of container lifecycle.
// However, docker will remove container log after container is removed,
@ -296,7 +295,7 @@ func (ds *dockerService) RemoveContainer(containerID string) error {
if err != nil {
return err
}
err = ds.client.RemoveContainer(containerID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true})
err = ds.client.RemoveContainer(containerID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
if err != nil {
return fmt.Errorf("failed to remove container %q: %v", containerID, err)
}

View File

@ -237,7 +237,7 @@ func (ds *dockerService) RemovePodSandbox(podSandboxID string) error {
}
// Remove the sandbox container.
if err := ds.client.RemoveContainer(podSandboxID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true}); err != nil && !libdocker.IsContainerNotFoundError(err) {
if err := ds.client.RemoveContainer(podSandboxID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true, Force: true}); err != nil && !libdocker.IsContainerNotFoundError(err) {
errs = append(errs, err)
}