March 2, 2016

Cleanup Docker host

Today I was testing a project and noticed some error messags coming from the Postgres container about having no disk space. I did a quick docker-machine default ssh and found that one of the VM's mounts was full. Doing some searching I found a few commands to help cleanup my docker host.

The first command I used cleans up dangling images. First, I did a docker-machine ssh default to connect to my VM then ran the following command.

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

This freed up some space, but Docker was still hogging space on disk. I also had to clean up dangling volumes. Again, I sshed into the VM and then ran:

docker volume rm $(docker volume ls -qf dangling=true)

Be Careful

Don't be flippant and just run these commands without first ensuring you don't need anything that will be deleted.

Tags: Containers VM Images Docker Volumes