Docker - Images - Remove dangling images

Docker images consist of multiple layers.

Dangling images are layers that have no relationship to any tagged images.


To list dangling images:

docker images -f dangling=true

To remove dangling images:

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

or

docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

An alternative to listing dangling images:

docker images | awk '/<none>/ { print $3 }'