Getting Started with Docker Compose
Docker Compose lets you define and run multi-container applications with a single YAML file. This assumes Docker is already installed (see our Docker install guide).
1. Verify Compose is available
docker compose version2. Create a docker-compose.yml file
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./site:/usr/share/nginx/html
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: example
volumes:
- dbdata:/var/lib/postgresql/data
volumes:
dbdata:3. Start the stack
docker compose up -d4. Common commands
docker compose ps # list running services
docker compose logs -f # follow logs
docker compose down # stop and remove containersCompose is ideal for local development and simple production stacks where all services run on one host.