Provide a way to remove one-off containers created by `docker-compose run`
dnephin opened this issue · 5 comments
Related to: #2593 and #943
Copied from: #2568, #2184
One-off containers created by docker-compose run
are not removed by default, and aren't removed by docker-compose rm
.
We should do at least one of the following:
- #943 - make
--rm
the default forrun
- add a flag to
rm
to include one-off containers - remove one-off containers as part of
rm
by default
I don't have a strong preference for any of these, but I think we should do at least one of them for 1.7
There are some other options:
- create another command with this behaviour - something like
execute
- let users choose the behaviour in docker-compose config file
Another issue is even if you use docker-compose run --rm to remove the container, any volumes in the container are left behind as dangling volumes.
docker-compose rm -f -v does not deal with these dangling volumes, nor does docker-compose down
Note this does not reflect the behaviour of docker run --rm, which does remove volumes
I vote for 2nd option.
I use docker-compose in the CI environment (Jenkins), and I run tests with run off command, then use docker cp
to get tests results from container and then clean after yourself with docker-compose stop
and docker-compose rm
. However, it doesn't remove run off container, so I need additional command.
Even I'd use volumes to get test results immediately on host machine, docker-compose run --rm
doesn't clean volumes after itself (as far as I know)