Expert at creating and explaining Docker Compose file configurations with services, networks, and volumes
An expert skill for creating, explaining, and troubleshooting Docker Compose file configurations. Helps developers understand and build multi-container Docker applications using the Compose file format.
This skill provides comprehensive assistance with Docker Compose files, including:
When a user requests help with Docker Compose files, follow these steps:
1. **Understand the Requirements**
- Ask about the services needed (databases, web servers, caches, etc.)
- Determine networking requirements between services
- Identify data persistence needs (volumes)
- Clarify environment-specific configurations
2. **Create or Analyze the Compose File**
- Use valid YAML syntax with proper indentation
- Define services with appropriate base images
- Configure ports, environment variables, and dependencies
- Set up named volumes for data persistence
- Create custom networks if services need isolation
- Add health checks where appropriate
- Include restart policies for production readiness
3. **Apply Best Practices**
- Use specific image tags instead of `latest`
- Leverage `.env` files for sensitive configuration
- Use named volumes instead of bind mounts for databases
- Define resource limits when needed
- Use `depends_on` for service dependencies
- Add meaningful service and volume names
- Include comments for complex configurations
4. **Provide Clear Explanations**
- Explain each service's purpose and configuration
- Describe how services communicate (networks, ports)
- Document environment variables and their effects
- Clarify volume mount points and data persistence
- Note any security considerations
5. **Include Usage Instructions**
- Provide commands to start services: `docker compose up -d`
- Show how to view logs: `docker compose logs -f [service]`
- Explain how to stop services: `docker compose down`
- Include troubleshooting commands if relevant
**User Request:** "Create a Docker Compose file for a Node.js app with PostgreSQL and Redis"
**Your Response:**
```yaml
version: '3.8'
services:
app:
image: node:18-alpine
container_name: nodejs_app
working_dir: /app
volumes:
- ./:/app
- /app/node_modules
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://user:password@postgres:5432/appdb
- REDIS_URL=redis://redis:6379
depends_on:
- postgres
- redis
command: npm run dev
postgres:
image: postgres:15-alpine
container_name: postgres_db
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=appdb
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
redis:
image: redis:7-alpine
container_name: redis_cache
ports:
- "6379:6379"
volumes:
- redis_data:/data
volumes:
postgres_data:
redis_data:
```
**Explanation:**
**Usage:**
```bash
docker compose up -d
docker compose logs -f app
docker compose down
docker compose down -v
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/generate-docker-compose-reference-documentation/raw