docker-compose [stop | kill | rm]
will properly cleanup docker-compose up
.
But it does not appear to have worked for docker-compose run <SERVICE>
For example
Cleanup will remove cibackbeatbackbeatserver274_ci_1 but not cibackbeatbackbeatserver274_ci_run_1
$ docker-compose -f docker-compose.yml -p cibackbeatbackbeatserver274 run -T ci
Creating cibackbeatbackbeatserver274_redis_1...
Creating cibackbeatbackbeatserver274_database_1...
$ docker-compose -f docker-compose.yml -p cibackbeatbackbeatserver274 ps
Name Command State Ports
------------------------------------------------------------------------------------------
cibackbeatbackbeatserver274_ci_run_1 bin/run-tests.sh Up
cibackbeatbackbeatserver274_database_1 /docker-entrypoint.sh postgres Up 5432/tcp
cibackbeatbackbeatserver274_redis_1 /entrypoint.sh redis-server Up 6379/tcp
where
$ docker-compose -f docker-compose.yml -p cibackbeatbackbeatserver274 kill
$ docker-compose -f docker-compose.yml -p cibackbeatbackbeatserver274 rm -v --force
Does not properly cleanup docker-compose run <SERVICE>
$ docker-compose -f docker-compose.yml -p cibackbeatbackbeatserver274 ps
Name Command State Ports
------------------------------
cibackbeatbackbeatserver274_ci_run_1 bin/run-tests.sh Up
So I ended up having to bash trap
$ for i in `docker-compose -f docker-compose.yml -p cibackbeatbackbeatserver274 ps -q`; do docker kill $i; docker rm -v --force $i; done
To ensure a complete cleanup per
$ docker-compose -f docker-compose.yml -p cibackbeatbackbeatserver274 ps
Name Command State Ports
------------------------------
I forget why it is we do this, but I think we should at least provide a flag to --rm
to remove them, if not remove them by default.
You can use docker-compose run --rm
for now to remove them automatically when they exit.
I'll give that a try ... Ty
On Tuesday, October 13, 2015, Daniel Nephin [email protected]
wrote:
I forget why it is we do this, but I think we should at least provide a
flag to --rm to remove them, if not remove them by default.You can use docker-compose run --rm for now to remove them automatically
when they exit.—
Reply to this email directly or view it on GitHub
https://github.com/docker/compose/issues/2184#issuecomment-147808217.
Turns out docker-compose run --rm
is not an option of DotCi jenkins plugin.
Otherwise jenkins is unable to retrieve artifacts from the build result.
At least now docker ps
will display the leaked container.
I'm closing this ticket and continuing the discussion instead by voting for issues #2593
Still experiencing this issue where I'll call docker-compose up -d <service>
and then docker-compose stop
and only my Postgres service will stop. Not my main. All of this talk seems to be about removing/killing one-offs but I can't just stop all of my containers successfully. Any ideas?
@kevingelion Have you tried docker-compose down --volumes
. I use that stop docker-compose processes on my mac client.
https://docs.docker.com/compose/reference/down/
Most helpful comment
@kevingelion Have you tried
docker-compose down --volumes
. I use that stop docker-compose processes on my mac client.https://docs.docker.com/compose/reference/down/