I cant find more information about those.
Should we use docker stop
for containers which we started with docker start
Or same for docker-compose up
?
What is the difference between stop and down?
The docker-compose stop command will stop your containers, but it won't remove them. The docker-compose down command will stop your containers, but it also removes the stopped containers as well as any networks that were created. You can take down 1 step further and add the -v flag to remove all volumes too.
docker-compose up : Builds, (re)creates, and starts containers. It also attaches to containers for a service. docker-compose start : Start the stopped containers, can't create new ones.
Stops containers and removes containers, networks, volumes, and images created by up . By default, the only things removed are: Containers for services defined in the Compose file.
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.
In docker-compose help
stop Stop services
down Stop and remove containers and networks (optionally images and volumes as well)
# Stop services only
docker-compose stop
# Stop and remove containers, networks..
docker-compose down
# Down and remove volumes
docker-compose down --volumes
# Down and remove images
docker-compose down --rmi <all|local>
Following are the differences among various docker-compose command options:
docker-compose up
- start and restart all the services defined in docker-compose.yml
docker-compose down
- command will stop running containers, but it also removes the stopped containers as well as any networks that were created. You can take down one step further and add the -v flag to remove all volumes too. This is great for doing a full blown reset on your environment by running docker-compose down -v
.
docker-compose start
- command will only restart containers stopped previously
docker-compose stop
- command will stop running containers but won’t remove them
Just to answer the other part of the question:
Use docker-compose up
to start or restart all the services defined in a docker-compose.yml
.
The docker-compose start
command is useful only to restart containers that were previously created, but were stopped. It never creates new containers.
The docker-compose run
command is for running “one-off” or “adhoc” tasks.
For further information visit this page.
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