Dangling or Unused Images in Docker
List Images
docker images
Filter Images
Filtering the docker images before or after the image
docker images -f since=<IMAGEID> # Get images sincedocker images -f before=<ImageID> # Get images Beforedocker images -f before=<ImagesID> -f since=<ImageId> # Get bwteen
Note : Filter are exclusive, it excludes the selected images and shows after or befor ethe images.
Dangling images are layers that have no relationship to any tagged images. They no longer serve a purpose and consume disk space. They can be located by adding the filter flag, -f
with a value of dangling=true
to the docker images
List Dangling images
docker images -f dangling=true
Remove single image or multiple images
docker rmi <imgae1-id> <image2-id> .....
Remove
Dangling images
docker rmi $(docker images -f dangling=true -q)
Remove all images
docker rmi $(docker rmi -q)
xargs
will need --no-run-if-empty
(-r
) to bypass executing docker rmi
with no arguments
docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi