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)
Error Handling
| Error |
Cause |
Solution |
port is already allocated |
Another container or host process using the same port |
Change the host port mapping or stop the conflicting process |
network not found |
Referenced network not defined in the compose file |
Add the network under the top-level networks: key |
service depends on undefined service |
Typo in depends_on or missing service definition |
Verify service names match exactly between depends_on and service definitions |
volume mount permission denied |
Host directory owned by different user than container process |
Use user: directive in service or set proper ownership with an init script |
OOM killed |
Container exceeded memory limit |
Increase deploy.resources.limits.memory or optimize application memory usage |
Examples
- "Generate a docker-compose.yml for a Node.js API + PostgreSQL + Redis stack with health checks, named volumes, and a development override with hot-reload."
- "Create a compose file for a WordPress site with MySQL, Nginx reverse proxy, and Certbot for automatic SSL certificate renewal."
- "Build a docker-compose stack for a microservices app with 3 APIs, RabbitMQ message broker, and a shared Postgres database with isolated networks."
Resources
Source: jeremylongshore/claude-code-plugins-plus-skills → skills/.curated/generating-docker-compose-files/SKILL.md
Also appears in: jeremylongshore/claude-code-plugins-plus-skills/plugins/devops/docker-compose-generator/skills/generating-docker-compose-files/SKILL.md
1---2name: generating-docker-compose-files3description: '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". '4---56# Generating Docker Compose Files78## Overview910Generate 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.1112## Prerequisites1314- Docker Engine 20.10+ and Docker Compose v2 (`docker compose version`)15- Application Dockerfiles for each service or pre-built images available16- Understanding of service dependencies and inter-service communication ports17- Environment variable values or `.env` files for configuration18- Sufficient disk space and memory for all containers defined in the stack1920## Instructions21221. Scan the project for existing Dockerfiles, `docker-compose*.yml` files, and application entry points232. Identify all services that compose the application stack (web server, API, database, cache, message queue, worker)243. Define each service with image or build context, port mappings, and environment variables254. Configure service dependencies using `depends_on` with health check conditions to ensure proper startup order265. Create named volumes for persistent data (database files, uploads, cache) and bind mounts for development hot-reload276. Define custom bridge networks to isolate service groups (frontend, backend, data tier)287. Add health checks for each service to enable dependency-aware startup and container orchestrator integration298. Set resource limits (`deploy.resources.limits`) for CPU and memory to prevent a single container from exhausting the host309. Create environment-specific override files: `docker-compose.override.yml` for development, `docker-compose.prod.yml` for production3110. Validate the configuration with `docker compose config` to check for syntax errors3233## Output3435- `docker-compose.yml` with service definitions, networks, and volumes36- Environment-specific override files (`docker-compose.override.yml`, `docker-compose.prod.yml`)37- `.env` file template with documented variables38- Dockerfiles for services that require custom builds39- Helper scripts for common operations (`start.sh`, `stop.sh`, `logs.sh`)4041## Error Handling4243| Error | Cause | Solution |44|-------|-------|---------|45| `port is already allocated` | Another container or host process using the same port | Change the host port mapping or stop the conflicting process |46| `network not found` | Referenced network not defined in the compose file | Add the network under the top-level `networks:` key |47| `service depends on undefined service` | Typo in `depends_on` or missing service definition | Verify service names match exactly between `depends_on` and service definitions |48| `volume mount permission denied` | Host directory owned by different user than container process | Use `user:` directive in service or set proper ownership with an init script |49| `OOM killed` | Container exceeded memory limit | Increase `deploy.resources.limits.memory` or optimize application memory usage |5051## Examples5253- "Generate a docker-compose.yml for a Node.js API + PostgreSQL + Redis stack with health checks, named volumes, and a development override with hot-reload."54- "Create a compose file for a WordPress site with MySQL, Nginx reverse proxy, and Certbot for automatic SSL certificate renewal."55- "Build a docker-compose stack for a microservices app with 3 APIs, RabbitMQ message broker, and a shared Postgres database with isolated networks."5657## Resources5859- Docker Compose specification: https://docs.docker.com/compose/compose-file/60- Docker Compose best practices: https://docs.docker.com/compose/production/61- Compose file versioning: https://docs.docker.com/compose/compose-file/compose-versioning/62- Multi-environment guide: https://docs.docker.com/compose/extends/6364---6566**Source:** [`jeremylongshore/claude-code-plugins-plus-skills`](https://github.com/jeremylongshore/claude-code-plugins-plus-skills) → `skills/.curated/generating-docker-compose-files/SKILL.md`6768**Also appears in:** `jeremylongshore/claude-code-plugins-plus-skills/plugins/devops/docker-compose-generator/skills/generating-docker-compose-files/SKILL.md`