How to force delete all podman images and children

Nagev picture Nagev · Aug 6, 2020 · Viewed 8.1k times · Source

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?

Answer

Nagev picture Nagev · Aug 6, 2020

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.