If you use docker for some time, there will be a lot of trash images, volumes that is not used by any containers. Here’s how to remove them. (warning: not reversible)
Remove dangling images
1 | docker rmi $(docker images -qf dangling=true) |
Remove dangling volumes
1 | docker volume rm $(docker volume ls -qf dangling=true) |
As seen from above commands, you may guess the nested command within the $(…) is used to list dangling images/volumes
List dangling images
1 | docker images -f dangling=true |
List dangling volumes
1 | docker volume ls -f dangling=true |