Currently, I use Docker Compose to start multiple containers in one shot. I have containers started and running already, but while doing docker-compose up -d
, I just want to exclude some containers while taking other containers up or down.
To stop one or more running Docker containers, you can use the docker stop command. The syntax is simple: $ docker stop [OPTIONS] CONTAINER [CONTAINER...] You can specify one or more containers to stop.
The docker compose up command aggregates the output of each container (like docker compose logs --follow does). When the command exits, all containers are stopped. Running docker compose up --detach starts the containers in the background and leaves them running.
It's a cool tool to make handling container configuration or multiple interconnected containers a bit easier. The “don't use docker-compose in production” statement is motivated by hidden assumptions which are not necessarily valid for everybody, and propagated by unclear communication.
Kill All Containers Using Docker Compose If you do, killing multiple containers takes one command: docker-compose down. You could also run docker-compose without detached mode.
Use the following to exclude specific services:
docker-compose up --scale <service name>=0
Think you have to go the "other way". You can start single containers from your docker-compose.yml via:
docker-compose up -d --no-deps ServiceName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With