docker-compose
Assists with defining and running multi-container applications using Docker Compose. Use when configuring services, networking, volumes, health checks, development environments with hot-reload, or production-ready compose files with resource limits. Trigger words: docker compose, docker-compose, multi-container, services, compose file, depends_on.
Usage
Getting Started
- Install the skill using the command above
- Open your AI coding agent (Claude Code, Codex, Gemini CLI, or Cursor)
- Reference the skill in your prompt
- The AI will use the skill's capabilities automatically
Example Prompts
- "Deploy the latest build to the staging environment and run smoke tests"
- "Check the CI pipeline status and summarize any recent failures"
Documentation
Overview
Docker Compose is a tool for defining and running multi-container applications using a declarative YAML file. It manages service definitions, networking between containers, persistent volumes, health checks, environment variables, and secrets, supporting both development workflows with hot-reload and production deployments with resource limits and logging.
Instructions
- When defining services, specify
imagefor pre-built containers orbuildfor Dockerfiles, setdepends_onwithcondition: service_healthyto prevent race conditions, and userestart: unless-stoppedfor production resilience. - When configuring networking, use the default bridge network for simple setups (services reach each other by name) or custom networks to isolate service groups (frontend, backend, database).
- When managing data, use named volumes for persistent data (databases, uploads), bind mounts for development source code, and
tmpfsfor scratch data. - When handling secrets, use
secretsorenv_filewith.gitignorerather than inlineenvironmentvalues, and use variable substitution with defaults (${DB_HOST:-localhost}). - When setting up development, use Compose Watch for file sync and auto-rebuild,
profilesfor optional services (monitoring, debug tools), andcompose.override.ymlfor dev-specific customization. - When preparing for production, set
deploy.resources.limitsfor CPU and memory caps, configure logging drivers with rotation, use multi-stage builds, and pin image tags to specific versions.
Examples
Example 1: Set up a full-stack development environment
User request: "Create a Docker Compose setup for a Node.js app with PostgreSQL and Redis"
Actions:
- Define
app,postgres, andredisservices with health checks - Configure bind mounts for source code and named volumes for database data
- Set up Compose Watch for hot-reload on file changes
- Add
.envfile for database credentials withenv_filereference
Output: A development environment where all services start with docker compose up, code changes hot-reload, and database data persists.
Example 2: Configure a production-ready multi-service deployment
User request: "Prepare a Docker Compose file for production with Nginx, API, and database"
Actions:
- Define services with pinned image tags, health checks, and
restart: unless-stopped - Set
deploy.resources.limitsfor CPU and memory on each service - Configure Nginx as reverse proxy with TLS termination and upstream load balancing
- Use Docker secrets for database passwords and API keys
Output: A production compose file with resource limits, health checks, TLS, secrets management, and automatic restart.
Guidelines
- Use health checks on every database and message queue service to prevent race conditions with
depends_on. - Use named volumes for persistent data and bind mounts only for development source code.
- Never put secrets in
environment; usesecretsorenv_filewith.gitignore. - Set
restart: unless-stoppedin production so services recover from crashes automatically. - Use
profilesfor optional services like monitoring and debug tools to avoid bloating the default stack. - Pin image tags (
postgres:16.2-alpine, neverpostgres:latest) for reproducible builds. - Set resource limits with
deploy.resources.limitsto prevent one service from starving others.
Information
- Version
- 1.0.0
- Author
- terminal-skills
- Category
- DevOps
- License
- Apache-2.0