Home » how to delete dangling docker images

how to delete dangling docker images

Let’s start the discussion about how to delete dangling docker images in following methods.

A dangling image simply indicates that you made a fresh build of the image but did not rename it. As a result, the old photographs you have became the “dangling image.” When you run docker images, the old images are untagged and display “<None>” in their name.

how to delete dangling docker images

Docker images are made up of numerous layers. Dangling images are layers that are unrelated to any tagged photos. They are no longer useful and take up disc space. Use the below command to remove the dangling docker images.

sudo docker rmi $(sudo docker images -f "dangling=true" -q)

you can also try :

docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi

Docker remove images using prune Flag

When you run docker system prune -a, you will get rid of both unused and dangling images. As a result, any images utilised in a container, whether they have been exited or are presently running, will be unaffected.

Run the below command :

docker image prune

I hope the strategies listed above work for you. Happy coding and come back again.

Similar Post : How to remove node modules from git