docker compose up
Create and start containers defined in a docker-compose.yml file. Builds images if needed.
Syntax
docker compose up [OPTIONS] [SERVICE...]
Examples
Example 1
docker compose up
Start all services in foreground.
Example 2
docker compose up -d
Start all services in detached mode.
Example 3
docker compose up -d --build web
Build and start only the web service.
Example 4
docker compose up -d --force-recreate
Recreate containers even if config unchanged.
Common flags
| Flag | Description |
|---|---|
| -d, --detach | Run in background |
| --build | Build images before starting |
| --force-recreate | Recreate containers |
| -q, --quiet | Pull without progress output |
Tips & best practices
- •Use -d for long-running stacks.
- •docker-compose.yml is the default file; use -f for others.