Contents
Docker Compose Down Tutorial: Stop and Remove Containers, Networks, and Volumes
docker compose down stops and removes the containers and networks for a Compose project.
Syntax
docker compose down [OPTIONS] [SERVICE...]
| Option | Description |
|---|---|
-v, --volumes | Also remove named and anonymous volumes declared in compose.yaml (data will be lost) |
--rmi local|all | Also remove images. local removes only images without a custom tag (those built by Compose); all removes all images used by the services |
--remove-orphans | Also remove containers for services that are no longer defined in compose.yaml |
-t, --timeout SECONDS | Seconds to wait when stopping containers (10 seconds by default) |
--dry-run | Only show what would happen |
Example
The example project from docker compose up:
$ docker compose down
[+] down 4/4
✔ Container ref-compose-worker-1 Removed 0.0s
✔ Container ref-compose-web-1 Removed 0.2s
✔ Container ref-compose-cache-1 Removed 0.2s
✔ Network ref-compose_default Removed 0.0s
$ docker volume ls
DRIVER VOLUME NAME
local ref-compose_cache_data
$ docker compose up -d
[+] up 4/4
✔ Network ref-compose_default Created 0.0s
✔ Container ref-compose-worker-1 Started 0.3s
✔ Container ref-compose-cache-1 Started 0.6s
✔ Container ref-compose-web-1 Started 0.8s
$ docker compose down -v -t 1
[+] down 5/5
✔ Container ref-compose-web-1 Removed 0.1s
✔ Container ref-compose-worker-1 Removed 0.0s
✔ Container ref-compose-cache-1 Removed 0.2s
✔ Volume ref-compose_cache_data Removed 0.0s
✔ Network ref-compose_default Removed 0.0s
$ docker volume ls
DRIVER VOLUME NAME
downwithout options: removes the 3 containers and the network, but keeps the volumeref-compose_cache_data.down -v -t 1: also removes the volume, so the Redis data is lost.-t 1waits at most 1 second for each container before force-stopping it, which can speed things up in a practice environment. In production, keep the default so the application has time to shut down cleanly.
Choosing between down, stop, and rm
| Command | Containers | Network | Volume | Use |
|---|---|---|---|---|
docker compose stop | Stopped, kept | Kept | Kept | Pause services and resume them later with start |
docker compose rm | Removes stopped containers | Kept | Kept | Rarely used on its own |
docker compose down | Stops and removes | Removed | Kept | Normal shutdown; data stays safe |
docker compose down -v | Stops and removes | Removed | Removed | Start completely over, such as reinitializing a database |
Database initialization scripts and password variables take effect only when the volume is empty. So use
down -vwhen you change settings and want to reinitialize; see MySQL for details.
Related chapters
Exercises
Exercise: Use one command to stop and remove the project's containers, network, and images built by Compose, while keeping the data.
Answer
docker compose down --rmi local
Without -v, the volumes are kept.
FAQ
Does docker compose down delete database data?
**No**, not without an option. Volumes are kept, and your data will still be there the next time you run up. Add -v to delete the volumes declared in compose.yaml.
Are images still there after down?
Yes. Use --rmi local to delete images built by Compose, or --rmi all to also delete downloaded images.
What if I only want to stop temporarily without deleting containers?
Use docker compose stop, then run docker compose start to resume.
Updated October 14, 2026