docker:images:remove_dangling_images
Docker - Images - Remove dangling images
Docker images consist of multiple layers.
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 command.
- When you're sure you want to delete them, you can add the -q flag, then pass their ID to docker rmi:
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 }'
docker/images/remove_dangling_images.txt · Last modified: 2022/09/19 14:15 by peter