LinuxCommandLibrary

docker-compose-down

Stop and remove Docker Compose services

TLDR

Stop and remove all containers and networks

$ docker compose down
copy

Stop and remove containers, networks, and all images used by services
$ docker compose down --rmi all
copy

Stop and remove containers, networks, and only images without a custom tag
$ docker compose down --rmi local
copy

Stop and remove containers, networks, and all volumes
$ docker compose down [[-v|--volumes]]
copy

Stop and remove everything including orphaned containers
$ docker compose down --remove-orphans
copy

Stop and remove containers using an alternate compose file
$ docker compose [[-f|--file]] [path/to/config] down
copy

Stop and remove containers with a custom timeout in seconds
$ docker compose down [[-t|--timeout]] [timeout]
copy

Remove containers for services not defined in the Compose file
$ docker compose down --remove-orphans [[-v|--volumes]]
copy

SYNOPSIS

docker-compose down [OPTIONS] [SERVICE...]

PARAMETERS

--volumes, -v
    Remove named volumes declared in the volumes section and anonymous volumes attached to containers

--rmi all|local
    all: remove all images used by stack; local: remove local images without custom tags

--remove-orphans
    Remove containers for services not defined in the Compose file

-t, --timeout TIMEOUT
    Graceful shutdown timeout in seconds (default: 10)

DESCRIPTION

The docker-compose down command stops and removes containers, networks, and optionally volumes and images defined in a Docker Compose file (typically docker-compose.yml). It sends a SIGTERM signal to containers, waiting up to 10 seconds by default before forcing shutdown with SIGKILL. Networks created by Compose are always removed, but volumes and images are preserved unless specified otherwise. This command is essential for cleaning up after development or testing sessions, reverting the environment to a clean state. It targets the default project name derived from the directory or explicitly set via COMPOSE_PROJECT_NAME. When service names are provided, only those services and their dependencies are affected. Orphaned containers (not in the Compose file) can be removed with an option. Ideal for workflows involving docker-compose up followed by down to manage ephemeral services.

CAVEATS

Preserves volumes and images by default; does not delete the Compose file or project directory. Use with caution in production to avoid data loss.

EXAMPLES

docker-compose down
Stop and remove all services.

docker-compose down --volumes --rmi all
Full cleanup including volumes and images.

docker-compose down --remove-orphans -t 30
Remove orphans with 30s timeout.

HISTORY

Introduced in Docker Compose 1.0 (2014) as part of core lifecycle management. Evolved with v1.6+ adding volume/image removal; now integrated as docker compose down plugin in Docker CLI v2+.

SEE ALSO

docker-compose up(1), docker-compose ps(1), docker rm(1), docker volume rm(1)

Copied to clipboard