/docker-skills:docker-compose-patternsfrom docker-skills
Provides patterns for creating, modifying, and debugging Docker Compose configurations. Covers service definitions, health checks, dependency ordering, volumes, networks, environment variables, and development overrides.
Ships in docker-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill provides rules for creating, reviewing, and debugging Docker Compose configurations. Use it when the main artifact is compose.yaml or compose.override.yaml and the task is about service wiring rather than image-build internals.
Activate this skill when:
compose.yaml for a projectcompose.override.yamlDo not use this skill when:
DockerfileUse compose.yaml as the canonical filename. Do not use docker-compose.yml or docker-compose.yaml — those are legacy names.
web, db, cache, worker.latest or omit the tag.restart: unless-stopped for long-running infrastructure services and non-development deployments.container_name only when external tools need a predictable name. Otherwise, let Compose generate names.depends_on with condition: service_healthy for services that must be ready before dependents start.depends_on with a health condition must have a healthcheck defined.depends_on without conditions — it only guarantees container start, not readiness.healthcheck to database services (Postgres, MySQL, Redis, MongoDB).pg_isready, redis-cli ping, mysqladmin ping).interval, timeout, retries, and start_period values. Start with: interval: 5s, timeout: 3s, retries: 3, start_period: 10s.Distroless, scratch-based, and hardened images contain no shell, curl, or wget. Do not bake tools into these images — that defeats their purpose. Instead, use a healthcheck sidecar that shares the application's network namespace:
services:
api:
build:
context: .
target: runtime # distroless / hardened image
ports:
- "8080:8080"
# No healthcheck here — the image has no tools to run one
api-health:
image: curlimages/curl:8.22.0
network_mode: "service:api" # shares api's localhost
entrypoint: ["sleep", "infinity"] # keep sidecar alive for healthcheck
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 45s
deploy:
resources:
limits:
memory: 32M
Key points:
entrypoint: ["sleep", "infinity"] so Compose can execute the healthcheck inside it.network_mode: "service:api" makes localhost inside the sidecar resolve to the api container's loopback — no extra networking needed.api being ready should reference the sidecar, not the api directly: worker:
depends_on:
api-health:
condition: service_healthy
volumes: key.networks: key to define all custom networks.environment: for non-sensitive values that are few in number.env_file: pointing to a .env file for longer lists of variables.compose.yaml. Use env_file: or Docker secrets.environment: block for local development, use variable substitution with fallbacks: ${DB_PASSWORD:-postgres}. Never write bare plaintext values for password fields..env to .gitignore.compose.override.yaml for development-only settings. Compose loads it automatically alongside compose.yaml.develop.watch for file-syncing and auto-rebuild in development when supported.compose.yaml and override only what changes for development.develop.watch over manual bind mounts for development workflows.action: sync for files that should be copied into the container on change (source code).action: rebuild for files that require a full image rebuild (dependency files like package.json, requirements.txt).action: sync+restart for configuration files that need a process restart.Some Compose commands delete data irreversibly. Before running any of the following, state exactly which data will be deleted and get explicit confirmation from the user — do not run them as a side effect of debugging, restarting, or "cleaning up" a stack:
docker compose down -v / docker compose down --volumes — deletes named volumes, including database data.docker volume rm / docker volume prune run against a Compose project's volumes — deletes volumes directly. For the standalone case (no Compose project in play), see docker-destructive-guardrails instead. A volume referenced via external: true isn't managed by the Compose project either (down -v won't touch it) — treat it as the standalone case too: run docker volume rm without -f first, and get explicit confirmation before deleting it.docker compose rm -v — deletes anonymous volumes attached to removed containers.If the goal is only to restart services or reclaim containers/networks, use docker compose down (no -v) or docker compose restart instead — these leave named volumes intact.
docker-project-foundations..dockerignore, use docker-build-strategies.docker system prune, docker rm -f, image/network/builder pruning, standalone volume deletion) and a cross-product index of destructive-command guardrails, use docker-destructive-guardrails.references/service-dependencies.md — Detailed guidance on depends_on, health check patterns for common databases, and startup ordering strategies.references/volumes-and-networks.md — Patterns for volume mounts, named volumes, bind mounts, and network configuration.assets/compose-web-app.yaml — Complete multi-service web app (app + Postgres + Redis) with health checks, dependencies, and named volumes.assets/compose-dev-override.yaml — Development override showing bind mounts, debug ports, and Compose Watch configuration.assets/bad-vs-good.md — Before/after comparisons of common Compose mistakes and their fixes.scripts/verify-compose.sh — Validates the Compose project in the current directory with docker compose config --quiet, without printing resolved configuration. Run it from the project root (the directory that contains compose.yaml), with the script path resolved under this skill's directory:
bash "<skill-dir>/scripts/verify-compose.sh" [--help]
Replace <skill-dir> with the absolute path of the folder that contains this SKILL.md; the scripts/ path is relative to that folder, not to the project. Do not change into the skill directory first: the script validates whatever Compose project is in the current directory. If the script is missing (some distributions, such as the Claude plugin, omit scripts/) or the skill directory cannot be resolved, run docker compose config --quiet directly. Exit status is 0 when the Compose configuration is valid or help is requested, the non-zero status from docker compose config --quiet when validation fails, and 2 for invalid arguments. Plain docker compose config can expose interpolated and env_file credentials in tool output or logs; use quiet validation by default. Compose warnings and errors are still emitted and may contain sensitive details.checks/verification.md — Detailed verification runbook for manual review.agents/openai.yaml (opens in a new tab)assets/bad-vs-good.md (opens in a new tab)assets/compose-dev-override.yaml (opens in a new tab)assets/compose-web-app.yaml (opens in a new tab)checks/verification.md (opens in a new tab)evals/docker-compose-patterns.md (opens in a new tab)references/service-dependencies.md (opens in a new tab)references/volumes-and-networks.md (opens in a new tab)scripts/verify-compose.sh (opens in a new tab)skill.yaml (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub docker/skills --plugin docker-skills11 skills in this plugin
/docker-agent-configUse this skill when creating or editing an agent.yaml (or .yml/.hcl) configuration file for Docker Agent (cagent), including defining agents, models/providers, built-in or MCP toolsets, multi-agent teams with sub_agents. Even if the user just says they want to "build an AI agent with Docker", "make a coding agent config", "add a tool to my agent", or "set up a team of agents", this skill applies. Covers agent properties (model, instruction, toolsets, sub_agents, fallback), the models/providers sections, built-in toolsets (filesystem, shell, think, todo, memory, fetch), MCP toolset references, and named commands./docker-agent-deployUse this skill when exposing a Docker Agent as a server (MCP, HTTP API, A2A, ACP, or OpenAI-compatible chat), distributing an agent via an OCI registry with `docker agent share`, or measuring agent quality with `docker agent eval`. Even if the user just says they want to "turn my agent into an MCP server", "let Claude Desktop use my agent", "publish my agent to Docker Hub", "push my agent like an image", or "test my agent in CI", this skill applies. Covers `serve mcp/api/a2a/acp/chat` listen addresses and auth flags, `share push/pull`, eval session JSON format, scoring metrics, and the `--baseline` regression gate./docker-agent-runUse this skill when running a Docker Agent with `docker agent run`, choosing a safety/approval mode, using the `--sandbox` isolation flag, setting up aliases, or troubleshooting a run (missing credentials, worktrees). Even if the user just says they want to "run my agent", "make my agent auto-approve tool calls", "run this agent safely", or "why can't my agent see my API key", this skill applies. Covers `--safety` (strict/balanced/restricted/autonomous), `--yolo`, `--sandbox` and its network allowlist, `--worktree`, `docker agent alias`, and `docker agent doctor`./docker-build-strategiesUse this skill when writing, reviewing, or optimizing Dockerfiles, even if the user just says their image is too large, their build is slow, or they need to harden a container for production. Covers multi-stage builds, layer caching, .dockerignore, non-root users, and image size optimization./docker-destructive-guardrailsUse this skill before running, or recommending, any Docker command that deletes, wipes, resets, or otherwise irreversibly changes state — even if the user just says to "clean up", "clear the cache", "start fresh", "wipe everything", "nuke it", "reset", "force remove", or "tear down" Docker resources. Covers generic Docker CLI destructive operations not owned by a more specific skill — `docker rm`, `docker rm -f`, `docker container prune`, `docker kill`, `docker system prune`, `docker rmi`/`docker image rm`, `docker image prune -a`, `docker network rm`, `docker network prune`, `docker builder prune`, `docker buildx rm`, `docker context rm`, and standalone (non-Compose) `docker volume rm`/`docker volume prune`. Also indexes destructive commands owned by other Docker skills (Compose, sandbox, Desktop). Core rule — state exactly what will be lost and get explicit confirmation first, except narrow, low-friction Tier 1 container cleanup./docker-docsUse this skill to answer questions about any Docker product from current official Docker documentation instead of memory, even if the user just asks "how do I…", "does Docker support…", "what's the flag for…", or "is this still the right way" about Docker. Covers Docker Desktop, Engine, Build/Buildx/Build Cloud, Compose, Hub, Scout, Docker Hardened Images (DHI), Offload, Testcontainers, Docker Sandboxes (`sbx`, local and cloud sandboxes, Sandboxes API/SDK), Docker Agentic Platform, Docker Agent, MCP Catalog/Toolkit/Gateway, Model Runner, Gordon, and account, admin, security, and billing docs. Searches with the `search_docker_docs` MCP tool when available and otherwise falls back to `docs.docker.com/llms.txt` and per-page Markdown.Other plugins' skills for the same job