| name | docker-compose-setup |
| description | Set up multi-container applications with Docker Compose including services, networks, and volumes |
| sasmp_version | 1.3.0 |
| bonded_agent | 05-docker-compose |
| bond_type | PRIMARY_BOND |
Docker Compose Setup Skill
Master Docker Compose for multi-container application orchestration with service dependencies, health checks, and environment management.
Purpose
Design and configure Docker Compose files for development and production environments with proper service orchestration.
Parameters
| Parameter | Type | Required | Default | Description |
|---|
| services | array | No | - | List of services to configure |
| environment | enum | No | dev | dev/staging/prod |
| include_monitoring | boolean | No | false | Add monitoring services |
Modern Compose File (2024-2025)
Note: The version field is deprecated. Start directly with services:.
services:
frontend:
build:
context: ./frontend
target: production
ports:
- "80:80"
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
backend:
build: ./backend
expose:
- "3000"
environment:
DATABASE_URL: postgres://user:${DB_PASSWORD}@database:5432/app
depends_on:
database:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 5
database:
[, ]
Environment Management
Base + Override Pattern
services:
app:
image: myapp:latest
services:
app:
build: .
volumes:
- ./src:/app/src
environment:
- DEBUG=true
services:
app:
deploy:
replicas: 3
restart: always
docker compose up
docker compose -f docker-compose.yaml -f docker-compose.prod.yaml up -d
Environment Variables
DB_PASSWORD=secret123
APP_VERSION=1.2.3
environment:
- DB_PASSWORD=${DB_PASSWORD}
- VERSION=${APP_VERSION:-latest}
Service Profiles
services:
app:
image: myapp
debugger:
image: debug-tools
profiles:
- debug
test-db:
image: postgres:alpine
profiles:
- testing
docker compose up
docker compose --profile debug up
Common Commands
docker compose up -d
docker compose up -d --build
docker compose logs -f backend
docker compose up -d --scale backend=3
docker compose down -v
docker compose config
Error Handling
Common Errors
| Error | Cause | Solution |
|---|
undefined service | Dependency missing | Define service |
yaml syntax error | Indentation | Fix YAML |
port already in use | Port conflict | Change port |
healthcheck failing | Service not ready | Increase start_period |
Fallback Strategy
- Validate with
docker compose config
- Start services individually
- Use
--no-deps to skip dependencies
Troubleshooting
Debug Checklist
Health Check Debugging
docker inspect --format='{{json .State.Health}}' <container>
docker inspect --format='{{range .State.Health.Log}}{{.Output}}{{end}}' <container>
Usage
Skill("docker-compose-setup")
Related Skills
- docker-networking
- docker-volumes
- docker-production