docker-compose(1)
Define and run multi-container Docker applications using a YAML configuration file.
Synopsis
docker-compose [OPTIONS] COMMAND [ARGS]...Description
Docker Compose is a tool for defining and running multi-container Docker applications. You describe your application's services, networks, and volumes in a docker-compose.yml file, then use a single command to start, stop, and manage all containers.
Compose simplifies local development, testing, and CI/CD workflows by eliminating the need to run multiple docker commands. It's particularly useful for applications with dependencies like web servers, databases, and caches that need to communicate.
Common options
| Flag | What it does |
|---|---|
-f, --file FILE | Specify an alternate compose file (default: docker-compose.yml) |
-p, --project-name NAME | Set the project name (default: current directory name) |
--profile PROFILE | Specify a profile to enable (can be used multiple times) |
-d, --detach | Run containers in the background (for up command) |
--no-deps | Don't start linked services (for up and run commands) |
--scale SERVICE=NUM | Run NUM instances of a service (for up command) |
-e, --env-file FILE | Read environment variables from a file |
--remove-orphans | Remove containers for services not defined in compose file |
-v, --version | Show the version number |
--no-color | Disable colored output |
Examples
Start all services defined in docker-compose.yml in the foreground; creates networks, volumes, and containers as needed
docker-compose upStart all services in the background (detached mode); useful for long-running applications
docker-compose up -dStop and remove all containers, networks, and volumes defined in the compose file
docker-compose downList all running containers managed by this compose project with their status and ports
docker-compose psFollow (stream) logs from the 'web' service in real-time; omit service name to see all logs
docker-compose logs -f webExecute a command in the running 'db' service container; useful for interactive database access
docker-compose exec db psql -U postgresRebuild all service images without using cached layers; useful when dependencies change
docker-compose build --no-cacheRestart the 'web' service and immediately tail its logs to verify it started correctly
docker-compose restart web && docker-compose logs web