mirror of https://github.com/k3s-io/k3s
Merge pull request #10821 from jimmidyson/gc-container-volumes
Fixes #10803: Delete Docker container volumes on GCpull/6/head
commit
4421b3dfdd
|
@ -138,7 +138,7 @@ func (cgc *realContainerGC) GarbageCollect() error {
|
|||
// Remove unidentified containers.
|
||||
for _, container := range unidentifiedContainers {
|
||||
glog.Infof("Removing unidentified dead container %q with ID %q", container.name, container.id)
|
||||
err = cgc.dockerClient.RemoveContainer(docker.RemoveContainerOptions{ID: container.id})
|
||||
err = cgc.dockerClient.RemoveContainer(docker.RemoveContainerOptions{ID: container.id, RemoveVolumes: true})
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to remove unidentified dead container %q: %v", container.name, err)
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ func (cgc *realContainerGC) removeOldestN(containers []containerGCInfo, toRemove
|
|||
// Remove from oldest to newest (last to first).
|
||||
numToKeep := len(containers) - toRemove
|
||||
for i := numToKeep; i < len(containers); i++ {
|
||||
err := cgc.dockerClient.RemoveContainer(docker.RemoveContainerOptions{ID: containers[i].id})
|
||||
err := cgc.dockerClient.RemoveContainer(docker.RemoveContainerOptions{ID: containers[i].id, RemoveVolumes: true})
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to remove dead container %q: %v", containers[i].name, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue