Cleaning up Docker volumes using Docker

A couple of months ago I wrote a script to delete orphaned Docker volumes. Several people have helped on Github to improve the script since. I also added a Docker file so you can cleanup Docker volumes using... Docker. I'm not entirely convinced it's easier than downloading the script and running that but hey, you can choose.

Run cleanup using Docker

Run using the latest Docker client version. Use the –-dry-run option to have the script print the volumes that would have been deleted without actually deleting them:

docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes --dry-run

or run a specific Docker client version, e.g. 1.4.1

docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes:1.4.1 --dry-run

View on Github or View on Docker registry