New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-compose run --rm does not remove volumes #2419
Comments
docker-compose run --rm
does not remove volumes
👍 |
We also ran into this. I am not 100% sure if this is related to an upgrade from 1.2.0 to 1.5.2, but it's the only change we've made.
CC: @Quexer69 |
That's strange, we've never set |
After digging through some code, I think it's very likely that someone ran also https://github.com/chadoe/docker-cleanup-volumes in a cronjob on the server. Is there another way to remove the volumes from a |
It seems a bit strange that a one-off container would use a volume and just remove it immediately. I would think that it would easier use a host volume, or a named volume that stays around. Is the volume just being created because the image has a volume in it?
|
This is a fundamental docker behaviour - if the image has volumes in it, they will created whenever you run a container from that image. It's common to run one off tasks from an image that has volumes you may never use for that task. The docker-compose run --rm behaviour should mirror the docker run --rm behaviour, which does correctly remove volumes. |
@dnephin Our use-case is a rather simple web-app. We usually have The volume is defined in
I also noticed that we ran a cleanup script before, I had to reactivate/fix that, but having an option to remove volumes after I need to look into named volumes a bit more I think, basically all apps we run, are running on a swarm, so I need to configure that properly. |
I also have this problem. I am using Docker Compose 1.7.1 |
same exact use case as @schmunk42. we use named volumes. |
You can work around this issue in Docker Compose 1.7 as follows:
The key here is to not use the |
For example given the following
If we use
Notice that the volume If we use
Everything is cleaned up correctly... |
Named volumes will not be removed. This is consistent with the behavior of docker run --rm. Fixes docker#2419, docker#3611
Named volumes will not be removed. This is consistent with the behavior of docker run --rm. Fixes docker#2419, docker#3611 Signed-off-by: Nikola Kovacs <nikola.kovacs@gmail.com>
Named volumes will not be removed. This is consistent with the behavior of docker run --rm. Fixes docker#2419, docker#3611 Signed-off-by: Nikola Kovacs <nikola.kovacs@gmail.com>
Can this be closed now? |
Is it fixed? My PR is still open. |
I also don't understand this issue. Using |
|
Pretty sure this issue was about |
It's not fixed in 1.10, I just tried it, and it doesn't look like it's fixed in master either (v=true is still missing): https://github.com/docker/compose/blob/master/compose/cli/main.py#L985 The issue is that --rm does not delete unnamed volumes. It should. |
Running one-off commands with docker-compose does not delete volumes used by the container. This is different than
docker run --rm
which does remove volumes after the container is deleted.The text was updated successfully, but these errors were encountered: