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
<code># Stop a single container docker stop <container-name> # Delete a single container docker rm <container-name></code>
Docker Compose
<code># Stop all containers defined in docker-compose.yml docker-compose down # Delete all containers defined in docker-compose.yml docker-compose down -v</code>
Docker
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 in docker-compose.yml
|
docker-compose down -v |
Stops and deletes all containers and associated volumes defined in docker-compose.yml
|
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
Stops a running container
docker rm
🎜Deletes a stopped container🎜🎜🎜Docker Compose🎜🎜🎜🎜🎜🎜Command🎜🎜Description🎜🎜🎜🎜🎜🎜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!