Home>Article>Operation and Maintenance> Docker/Docker-compose stop and delete container
This article provides commands to stop and delete containers using Docker and Docker Compose. It explains the syntax and usage of docker stop, docker rm, docker-compose down, and docker-compose down -v commands for stopping and deleting single and mu
Docker
# Stop a single container docker stop # Delete a single container docker rm
Docker Compose
# Stop all containers defined in docker-compose.yml docker-compose down # Delete all containers defined in docker-compose.yml docker-compose down -v
Docker
docker stop
Command | Description |
---|---|
docker stop |
Stops a running container |
docker rm |
Deletes a stopped container |
Docker Compose
Command | Description |
---|---|
docker-compose down |
Stops and deletes all containers defined indocker-compose.yml |
docker-compose down -v |
Stops and deletes all containers and associated volumes defined indocker-compose.yml |
Yes, you can usedocker-compose down
to stop and delete all containers defined indocker-compose.yml
simultaneously. To also remove the associated volumes, usedocker-compose down -v
Stops a running container
docker rm
Deletes a stopped containerDocker ComposeCommandDescription
docker-compose down
Stops and deletes all containers defined in
docker-compose.yml
docker-compose down -v
Stops and deletes all containers and associated volumes defined in
docker-compose.yml
Can I use Docker or Docker Compose to stop and delete all containers simultaneously?Yes, you can use
docker-compose down
to stop and delete all containers defined in
docker-compose.yml
simultaneously. To also remove the associated volumes, use
docker-compose down -v
.
The above is the detailed content of Docker/Docker-compose stop and delete container. For more information, please follow other related articles on the PHP Chinese website!