compose

docker compose

Manages multi-container applications defined in a compose.yaml file. This is the Compose V2 plugin invoked via 'docker compose' (space); the legacy hyphenated 'docker-compose' binary is deprecated.

docker compose [OPTIONS] COMMAND

Common flags

Flag Purpose
-f, --file Path to a compose file (repeatable to layer overrides)
-p, --project-name Set the project namespace (default: directory name)
-d, --detach Run 'up' in the background
--profile Enable services matching a profile
--build Build images before starting containers (with 'up')
-v, --volumes Remove named volumes (with 'down')

Examples

docker compose up -d

Start all services in detached mode

docker compose up -d --build web

Rebuild and start just the web service

docker compose down -v

Stop and remove containers, networks, and named volumes

docker compose -f compose.yaml -f compose.prod.yaml up -d

Layer a production override on top of the base file

Gotcha

Use 'docker compose' (space), not 'docker-compose' — the hyphenated V1 tool is end-of-life. 'down' does not remove named volumes unless you pass -v, which can silently retain stale data across recreations.

Related commands

← All Docker commands · Docker vs Kubernetes · Docker vs VMs