aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/rmi.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-12-04 10:14:13 -0600
committerbaude <bbaude@redhat.com>2018-12-04 13:13:54 -0600
commit41a7bd9c9e60283d893d9fca559d57338581058d (patch)
treeb6b0d4d9d72322deddcdb1ddb656a6ad6e6338b8 /cmd/podman/rmi.go
parent5f6ad82524ca7a3281c8464c84b4f9be4ff90aef (diff)
downloadpodman-41a7bd9c9e60283d893d9fca559d57338581058d.tar.gz
podman-41a7bd9c9e60283d893d9fca559d57338581058d.tar.bz2
podman-41a7bd9c9e60283d893d9fca559d57338581058d.zip
correct algorithm for deleting all images
when deleting all images, we need to iterate all the images deleting on those who dont have children first. And then reiterate until they are all gone. This resolves #1926 Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/rmi.go')
-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.