chadoe/docker-cleanup-volumes

Running from toolbox on mac, delete a volume that it is in use.

Closed this issue · 1 comments

Hallo,

Learning docker, I installed docker toolbox on my Mac and follow the docker book from James Turnbull.

$ docker-machine --version
docker-machine version 0.4.0 (9d0dc7a)

Run from my Mac.

$ 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 --verbose
dockerdir -> /var/lib/docker
dockerdir_match -> /var/lib/docker
Processing volumepath /var/lib/docker for container cf4df59e1a292b37ee52bd68cbe052ba64b9a5ba3759df37fad66bbcf1c50a68
Processing volumepath /var/run/docker.sock for container cf4df59e1a292b37ee52bd68cbe052ba64b9a5ba3759df37fad66bbcf1c50a68
Processing volumepath /Users/serege/thuis/docker/james_blog for container d03b3329be410d6d03f3484eb8b5ee1f2df8749bc60b67b08b1bf0549d71d4df
Processing volumepath /mnt/sda1/var/lib/docker/volumes/967e423a2c907eb4aa0ccbc1e33ffca3f8051859c4198f8247d1a7903a738132/_data for container d03b3329be410d6d03f3484eb8b5ee1f2df8749bc60b67b08b1bf0549d71d4df

Delete unused volume directories from /var/lib/docker/volumes
Would have deleted 967e423a2c907eb4aa0ccbc1e33ffca3f8051859c4198f8247d1a7903a738132

Directory /var/lib/docker/vfs/dir does not exist, skipping.

Why would it delete the volume when is has a volume path? Or did I need to run an other command?

Regards,
Gerrit

Hi, it deletes the volume because /var/lib/docker/volumes/967e423... volume is not used in any container on your system, /mnt/sda1/var/lib/docker/volumes/967e423... is.

This script is not compatible with things like boot2docker and docker machine. It should work if you run the script on the virtual machine those applicaitons create to run docker on, it won't work from your mac. Even inside the virtual machine you should probably run it including the mnt path because it seems to be using that as a custom path

 -v /mnt/sda1/var/lib/docker:/var/lib/docker

You could also try this fork which should work for boot2docker so also maybe for docker toolbox: https://github.com/dsanders11/docker-cleanup-volumes