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
docker run
Creates and starts a new container from a specified image in a single step. This is the primary command for launching workloads and supports extensive configuration for networking, storage, and process control.
docker build
Builds an image from a Dockerfile and a build context. In Docker 23+ this invokes BuildKit by default and supports multi-platform, secrets, and cache mounts.
docker network
Manages Docker networks — create, inspect, connect, disconnect, and remove user-defined bridges, overlays, or macvlan networks. Enables container-to-container DNS resolution by name.
docker volume
Manages persistent named volumes for containers — create, list, inspect, remove, and prune. Named volumes survive container removal and are the recommended storage mechanism over bind mounts for stateful data.
← All Docker commands · Docker vs Kubernetes · Docker vs VMs