Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force delete all podman images and children

Tags:

podman

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?

like image 509
Nagev Avatar asked Aug 06 '20 16:08

Nagev


People also ask

How do I remove all podman containers?

To remove the containers that you no longer need, first, ensure that you stop it and then invoke the podman rm command followed by the container id or name as an option. To remove multiple containers at a go in one command, specify the container ids separated by a space.

Where are the podman images stored?

By default, images are stored in the /var/lib/containers directory when Podman is run by the root user. For standard users, images are typically stored in $HOME/. local/share/containers/storage/ . These locations conform to Open Container Inititiative (OCI) specifications.

Does podman RMI--all remove all images?

(Sorry I pressed Enter too quickly, I edit the message and title). podman rmi --all doesn't remove all images. Example:

What is dangling image in podman?

A dangling image is an image without a tag and without being referenced by another image. Remove all images in the local storage. This option will cause podman to remove all containers that are using the image before removing the image from the system. Remove an image and its associated containers.

Why can’t I delete storage created by non-root podman?

Why can’t I delete storage files created by non-root Podman? When running Podman as root, the default location for storage is /var/lib/containers/storage. Of course, users cannot use this directory when running as non root, so Podman creates the storage by default in $HOME/.local/share/containers.

What is * unable to delete XXXXX (must force)?

* unable to delete xxxxx (must force) - image is referred to in multiple tags: image is being used. Basically, the image with the same id exist twice. It is in the remote and local repository of images. The solution for solving the problem exist in the introduction part is simple.


2 Answers

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.

like image 104
Nagev Avatar answered Oct 12 '22 05:10

Nagev


you can reset the entire storage with podman system reset

like image 8
Giuseppe Scrivano Avatar answered Oct 12 '22 06:10

Giuseppe Scrivano