summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-12-04 11:50:15 -0800
committerGitHub <noreply@github.com>2018-12-04 11:50:15 -0800
commitf31c1c8c09c8dd1468093e0d891ff110d48f5461 (patch)
treedff7ac3e155074639ef2ff525203058df9c1fe98 /cmd
parent480a179f019c343d8f778c0e0576390e7130b375 (diff)
parent41a7bd9c9e60283d893d9fca559d57338581058d (diff)
downloadpodman-f31c1c8c09c8dd1468093e0d891ff110d48f5461.tar.gz
podman-f31c1c8c09c8dd1468093e0d891ff110d48f5461.tar.bz2
podman-f31c1c8c09c8dd1468093e0d891ff110d48f5461.zip
Merge pull request #1938 from baude/rmichildren
correct algorithm for deleting all images
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/rmi.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go
index c0a0d69df..0f4f8765b 100644
--- a/cmd/podman/rmi.go
+++ b/cmd/podman/rmi.go
@@ -91,8 +91,23 @@ func rmiCmd(c *cli.Context) error {
if err != nil {
return errors.Wrapf(err, "unable to query local images")
}
- for _, i := range imagesToDelete {
- removeImage(i)
+ lastNumberofImages := 0
+ for len(imagesToDelete) > 0 {
+ if lastNumberofImages == len(imagesToDelete) {
+ return errors.New("unable to delete all images; re-run the rmi command again.")
+ }
+ for _, i := range imagesToDelete {
+ isParent, err := i.IsParent()
+ if err != nil {
+ return err
+ }
+ if isParent {
+ continue
+ }
+ removeImage(i)
+ }
+ lastNumberofImages = len(imagesToDelete)
+ imagesToDelete, err = runtime.ImageRuntime().GetImages()
}
} else {
// Create image.image objects for deletion from user input.