Dangling docker volumes
As anyone who works with docker knows, images and containers accumulate rapidly.
All containers can be cleared down with
docker rm $(docker ps -a -q)
And likewise, all Images with
docker rmi -f $(docker images -q)
What I wasn’t aware of was the dangling volume issue. While I had no images or containers left after the above, I did however have 20Gb taken up in dangling volumes which I was oblivious to until I wondered where all my system space had disappeared to.
You can check for dangling volumes independent of containers with
docker volume ls -f dangling=true
And remove them with
docker volume rm $(docker volume ls -qf dangling=true)
Or you can remove them with the associated container by adding the –v
flag (e.g. docker rm –v container name
) if you remember to put the flag on every time.
I would suggest incorporating these to your team purge scripts/procedures for a better cleanup.
More information can be found here (recommended reading)