podman

How to force delete all podman images and children


When I do something like podman rmi d61259d8f7a7 -f it fails with a message: Error: unable to delete "vvvvvvvvvvvv" (cannot be forced) - image has dependent child images.

I already tried the all switch podman rmi --all which does delete some images but many are still left behind. How do I force remove all images and dependent child images in a single step?


Solution

  • Inspired by a similar docker answer with a slight modification, adding the a was the missing magic in my case:

    WARNING: This will delete every image! Please, check and double check that it is indeed what you need.

    $ podman rmi $(podman images -qa) -f
    

    Again, please use with caution and make sure you know what you're doing! Sharing here for my own future reference and hoping that it will save someone else some time.

    Thanks to the hint by @Giuseppe Scrivano there's an alternative which may be more natural (previous warning applies):

    podman system prune --all --force && podman rmi --all
    

    See podman system prune --help for details. I have not yet had a chance to verify that this second method fixes the "image has dependent child images" error.