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...]
OptionDescription
-v, --volumesAlso remove named and anonymous volumes declared in compose.yaml (data will be lost)
--rmi local|allAlso remove images. local removes only images without a custom tag (those built by Compose); all removes all images used by the services
--remove-orphansAlso remove containers for services that are no longer defined in compose.yaml
-t, --timeout SECONDSSeconds to wait when stopping containers (10 seconds by default)
--dry-runOnly 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
  • down without options: removes the 3 containers and the network, but keeps the volume ref-compose_cache_data.
  • down -v -t 1: also removes the volume, so the Redis data is lost. -t 1 waits 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

CommandContainersNetworkVolumeUse
docker compose stopStopped, keptKeptKeptPause services and resume them later with start
docker compose rmRemoves stopped containersKeptKeptRarely used on its own
docker compose downStops and removesRemovedKeptNormal shutdown; data stays safe
docker compose down -vStops and removesRemovedRemovedStart completely over, such as reinitializing a database

Database initialization scripts and password variables take effect only when the volume is empty. So use down -v when you change settings and want to reinitialize; see MySQL for details.

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