signalfx / maestro-ng

Orchestration of Docker-based, multi-host environments
https://signalfx.com
Apache License 2.0
683 stars 83 forks source link

docker volumes are not removed with container (dangling volumes) #122

Closed iangkent closed 9 years ago

iangkent commented 9 years ago

When maestro-ng call docker.py api it does not pass -v option to remove volume associated with container.

https://github.com/signalfuse/maestro-ng/blob/c41d69e484282d4b728adf6efd00c2947b3c5cd3/maestro/plays/tasks.py#L465 https://github.com/docker/docker-py/blob/ec85f126edfaaed8e9d081b3a69f3011fb51eaeb/docker/client.py#L819

Docker never automatically deletes volumes when you remove a container, nor will it "garbage collect" volumes that are no longer referenced by a container. Therefore any volumes declared in Dockerfile used to create docker container image will never be removed. Also if we specific volume in yaml file without host binding the same issue will happen. https://github.com/signalfuse/maestro-ng/pull/115

See: https://docs.docker.com/userguide/dockervolumes/, https://github.com/docker/docker/pull/8484

mpetazzoni commented 9 years ago

That is correct. In our use case we only have bind-mounted volumes so this has not been an issue.

The question is: "is asking for volume removal the correct thing to do?". Maybe you have data in this volume that you want to use? I don't know. If anybody has input on this, please speak up :)

TrustNoOne commented 9 years ago

my two cents: I keep using external tools (https://github.com/chadoe/docker-cleanup-volumes) to delete dangling volumes, so definitely yes.

thaJeztah commented 9 years ago

For those following this; top level volume management is now implemented in https://github.com/docker/docker/pull/14242, which was just merged, and will be in docker 1.9

If you want to test it before that, nightly builds, build from master can be found at https://master.dockerproject.org