| name | generating-docker-compose-files |
| description | Execute use when you need to work with Docker Compose.
This skill provides Docker Compose file generation with comprehensive guidance and automation.
Trigger with phrases like "generate docker-compose", "create compose file",
or "configure multi-container app".
|
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash(docker:*), Bash(kubectl:*) |
| version | 1.28.0 |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| license | MIT |
| tags | ["devops","docker","docker-compose"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Generating Docker Compose Files
Overview
Generate production-ready docker-compose.yml files for multi-container applications. Define services, networks, volumes, health checks, resource limits, and environment-specific overrides for local development, testing, and single-host production deployments.
Prerequisites
- Docker Engine 20.10+ and Docker Compose v2 (
docker compose version)
- Application Dockerfiles for each service or pre-built images available
- Understanding of service dependencies and inter-service communication ports
- Environment variable values or
.env files for configuration
- Sufficient disk space and memory for all containers defined in the stack
Instructions
- Scan the project for existing Dockerfiles,
docker-compose*.yml files, and application entry points
- Identify all services that compose the application stack (web server, API, database, cache, message queue, worker)
- Define each service with image or build context, port mappings, and environment variables
- Configure service dependencies using
depends_on with health check conditions to ensure proper startup order
- Create named volumes for persistent data (database files, uploads, cache) and bind mounts for development hot-reload
- Define custom bridge networks to isolate service groups (frontend, backend, data tier)
- Add health checks for each service to enable dependency-aware startup and container orchestrator integration
- Set resource limits (
deploy.resources.limits) for CPU and memory to prevent a single container from exhausting the host
- Create environment-specific override files:
docker-compose.override.yml for development, docker-compose.prod.yml for production
- Validate the configuration with
docker compose config to check for syntax errors
Output
docker-compose.yml with service definitions, networks, and volumes
- Environment-specific override files (
docker-compose.override.yml, docker-compose.prod.yml)
.env file template with documented variables
- Dockerfiles for services that require custom builds
- Helper scripts for common operations (
start.sh, stop.sh, logs.sh)