サービスの接続、ヘルスチェック、開発用オーバーライドを含む、Docker Compose設定の作成、レビュー、およびデバッグのためのルールを提供します。
- GitHubスター
- 626
- ファイル
- 10
- 最終コミット
- 2026年11月10日
- ライセンス
- Apache-2.0
- 許可されたツール
- —
docker-compose-patterns skillは何をしますか
docker-compose-patternsはAgent Skillsです。 サービスの接続、ヘルスチェック、開発用オーバーライドを含む、Docker Compose設定の作成、レビュー、およびデバッグのためのルールを提供します。.
skillのSKILL.mdから生成された要約。
docker-compose-patterns skill について
マルチコンテナ環境を構築する開発者は、このSKILLを使用してDocker Compose設定の作成、レビュー、デバッグを行うことができます。個々のDockerfileの最適化ではなく、サービスの接続とオーケストレーションに焦点を当てています。エージェントがこのSKILLをロードすると、compose.yamlおよびcompose.override.yamlファイルを管理するための具体的なルールが提供され、Docker Compose v2においてサービスの依存関係、ヘルスチェック、ネットワークが正しく構成されることを保証します。
このSKILLは、内部シェルを持たないdistrolessやscratchベースのイメージに対してヘルスチェック用サイドカーを実装するなど、複雑なシナリオに対する専門的なガイダンスを提供します。また、ボリュームの管理、env_fileを介した環境変数の管理、Compose Watchを使用した開発ワークフローに関する指示も提供します。ユーザーは検証スクリプトを実行して、ログに機密性の高い補完された認証情報を露出させることなく、現在のプロジェクト構成を検証することも可能です。
エージェントができること
- 1サービス起動の依存関係の設定データベースが完全に正常な状態(healthy)になった後にのみ、依存するアプリケーションコンテナが起動するようにデータベースサービスをセットアップします。
- 2セキュアなイメージへのヘルスチェック実装distrolessイメージ上で動作するAPIに対して、ヘルスチェックを実行するためのサイドカーコンテナを作成します。
- 3開発環境のオーバーライド管理本番環境のインフラ設定と、バインドマウントやデバッグポートなどのローカル開発用ツールを分離します。
- 4Compose設定ファイルの検証現在のディレクトリのcompose.yamlファイルに構文エラーや設定の問題がないかを確認します。
skill の SKILL.md から作成されています。すべてのユースケースは、その引用と照合されています。
docker-compose-patterns skillのインストール方法
各コマンドはskillフォルダをクライアントのskillsディレクトリにコピーします。読み込むには、クライアントを再起動するか新しいセッションを開始してください。プラグインにdocker-compose-patterns skillをインストールする
/plugin marketplace add docker/skills /plugin install docker-skills@docker
Claude Codeにdocker-compose-patterns skillをインストールする
~/.claude/skills/docker-compose-patterns/SKILL.md
$ npx degit docker/skills/skills/docker-compose-patterns ~/.claude/skills/docker-compose-patternsClaude Code (project)にdocker-compose-patterns skillをインストールする
.claude/skills/docker-compose-patterns/SKILL.md
$ npx degit docker/skills/skills/docker-compose-patterns .claude/skills/docker-compose-patternsCodexにdocker-compose-patterns skillをインストールする
~/.agents/skills/docker-compose-patterns/SKILL.md
$ npx degit docker/skills/skills/docker-compose-patterns ~/.agents/skills/docker-compose-patternsGemini CLIにdocker-compose-patterns skillをインストールする
~/.gemini/skills/docker-compose-patterns/SKILL.md
$ npx degit docker/skills/skills/docker-compose-patterns ~/.gemini/skills/docker-compose-patternsClaude.aiにdocker-compose-patterns skillをインストールする
npx degit docker/skills/skills/docker-compose-patterns docker-compose-patterns && zip -r docker-compose-patterns.zip docker-compose-patterns # claude.ai → Customize → Skills → + → Create skill → Upload a skill → docker-compose-patterns.zip
自動チェック
実行日 2026年11月14日詳細レポート →自動チェックに合格しました。これはセキュリティ監査ではありません。エージェントに実行させる前にスクリプトを読んでください。 チェックの仕組み
- ソースリポジトリがリンクされており、アクセス可能docker/skills/skills/docker-compose-patterns is public and reachablegithub.com/docker/skills/tree/HEAD/skills/docker-compose-pat ↗合格
- オープンソースライセンス (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit 2026-11-10github.com/docker/skills/commits ↗合格
- スクリプトにダウンロード実行や認証情報の窃取がない1 script read; no download-and-run, remote eval, base64 execution or credential upload合格
- SKILL.md に隠れた指示がないNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/docker/skills/blob/HEAD/skills/docker-compose-pat ↗合格
- 事前許可ツールが限定されているNo pre-approved tools; the agent asks before using onegithub.com/docker/skills/blob/HEAD/skills/docker-compose-pat ↗合格
SKILL.md
GitHubで表示Docker Compose Patterns
Overview
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.
When to use this skill
Activate this skill when:
- Creating a new
compose.yamlfor a project - Adding or modifying services in an existing Compose file
- Setting up development overrides with
compose.override.yaml - Debugging service startup ordering or connectivity issues
Do not use this skill when
Do not use this skill when:
- The project has no Docker setup yet and the main need is an initial scaffold
- The main task is writing or optimizing a
Dockerfile - The main task is improving build caching, image size, or runtime user configuration
Core guidance
File naming
Use compose.yaml as the canonical filename. Do not use docker-compose.yml or docker-compose.yaml — those are legacy names.
Service definitions
- Give services clear, lowercase names that reflect their role:
web,db,cache,worker. - Always pin image tags to a specific version. Never use
latestor omit the tag. - Set
restart: unless-stoppedfor long-running infrastructure services and non-development deployments. - Add
container_nameonly when external tools need a predictable name. Otherwise, let Compose generate names.
Dependency modeling
- Use
depends_onwithcondition: service_healthyfor services that must be ready before dependents start. - Every service listed in
depends_onwith a health condition must have ahealthcheckdefined. - Do not rely on
depends_onwithout conditions — it only guarantees container start, not readiness.
Health checks
- Always add a
healthcheckto database services (Postgres, MySQL, Redis, MongoDB). - Use the service's native client tool for health checks when available (e.g.,
pg_isready,redis-cli ping,mysqladmin ping). - Set reasonable
interval,timeout,retries, andstart_periodvalues. Start with:interval: 5s,timeout: 3s,retries: 3,start_period: 10s.
Health checks for distroless or scratch images
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:
- The sidecar must stay alive with
entrypoint: ["sleep", "infinity"]so Compose can execute the healthcheck inside it. network_mode: "service:api"makeslocalhostinside the sidecar resolve to the api container's loopback — no extra networking needed.- Keep the sidecar lightweight with a resource limit (32MB is sufficient for curl).
- Services that depend on
apibeing ready should reference the sidecar, not the api directly:
worker:
depends_on:
api-health:
condition: service_healthy
Volumes
- Use named volumes for data that must persist across container recreations (database data, uploaded files).
- Use bind mounts only for development-time source code syncing.
- Define all named volumes in the top-level
volumes:key. - Do not mount the Docker socket unless the service genuinely requires it.
Networks
- For single-application stacks, the default network is sufficient. Do not create custom networks unless you need isolation between service groups.
- When creating custom networks, prefer bridge driver and give networks descriptive names.
- Use the top-level
networks:key to define all custom networks.
Environment variables
- Use
environment:for non-sensitive values that are few in number. - Use
env_file:pointing to a.envfile for longer lists of variables. - Never hardcode secrets (passwords, API keys) directly in
compose.yaml. Useenv_file:or Docker secrets. - When defaults are needed in the
environment:block for local development, use variable substitution with fallbacks:${DB_PASSWORD:-postgres}. Never write bare plaintext values for password fields. - Add
.envto.gitignore.
Development overrides
- Use
compose.override.yamlfor development-only settings. Compose loads it automatically alongsidecompose.yaml. - Put bind mounts for source code, debug ports, and development environment variables in the override file.
- Use
develop.watchfor file-syncing and auto-rebuild in development when supported. - Keep production-oriented settings in the base
compose.yamland override only what changes for development.
Compose Watch
- Prefer
develop.watchover manual bind mounts for development workflows. - Use
action: syncfor files that should be copied into the container on change (source code). - Use
action: rebuildfor files that require a full image rebuild (dependency files likepackage.json,requirements.txt). - Use
action: sync+restartfor configuration files that need a process restart.
Destructive commands
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 prunerun against a Compose project's volumes — deletes volumes directly. For the standalone case (no Compose project in play), seedocker-destructive-guardrailsinstead. A volume referenced viaexternal: trueisn't managed by the Compose project either (down -vwon't touch it) — treat it as the standalone case too: rundocker volume rmwithout-ffirst, 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.
Related skills
- For first-time Docker project scaffolding and baseline file creation, use
docker-project-foundations. - For Dockerfile internals, build caching, multi-stage builds, and
.dockerignore, usedocker-build-strategies. - For destructive Docker CLI commands outside Compose (
docker system prune,docker rm -f, image/network/builder pruning, standalone volume deletion) and a cross-product index of destructive-command guardrails, usedocker-destructive-guardrails.
References
references/service-dependencies.md— Detailed guidance ondepends_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
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
scripts/verify-compose.sh— Validates the Compose project in the current directory withdocker compose config --quiet, without printing resolved configuration. Run it from the project root (the directory that containscompose.yaml), with the script path resolved under this skill's directory:
Replacebash "<skill-dir>/scripts/verify-compose.sh" [--help]<skill-dir>with the absolute path of the folder that contains thisSKILL.md; thescripts/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 skill directory cannot be resolved, rundocker compose config --quietdirectly. Exit status is0when the Compose configuration is valid or help is requested, the non-zero status fromdocker compose config --quietwhen validation fails, and2for invalid arguments. Plaindocker compose configcan expose interpolated andenv_filecredentials in tool output or logs; use quiet validation by default. Compose warnings and errors are still emitted and may contain sensitive details.
Checks
checks/verification.md— Detailed verification runbook for manual review.
このスキルのファイル
10docker-compose-patterns skillに関する質問
Claude Codeにdocker-compose-patterns skillをインストールするには
npx degit docker/skills/skills/docker-compose-patterns ~/.claude/skills/docker-compose-patternsを実行してください。Claude Codeは~/.claude/skills(すべてのプロジェクト)または.claude/skills(単一プロジェクト)からskillsを読み込み、説明がタスクに一致する場合にskillを使用します。
docker-compose-patterns skillはどのクライアントで使用できますか
Agent Skills形式を読み込むすべてのクライアントで使用できます: Claude Code、Codex、Gemini CLI、claude.ai(ZIPとしてアップロード)。skill内のスクリプトは、クライアントがコード実行を許可した場合にのみ実行されます。
Docker Composeファイルの推奨されるファイル名は?
従来の docker-compose.yml や docker-compose.yaml ではなく、標準的なファイル名として compose.yaml を使用してください。
distrolessやscratchイメージのヘルスチェックはどのように扱うべきですか?
これらのイメージにはシェルやcurlなどのツールが含まれていないため、network_mode: "service:api" を使用してアプリケーションのネットワーク名前空間を共有するヘルスチェック用サイドカーを利用してください。
取り返しのつかないデータ損失を招く可能性があるDocker Composeコマンドはどれですか?
docker compose down -v、docker volume rm、docker compose rm -v などのコマンドは、データベースのデータを含む名前付きボリュームや匿名ボリュームを削除する可能性があります。
メインの設定を変更せずに、開発専用の設定を管理するにはどうすればよいですか?
バインドマウントやデバッグポートなどの開発時のみ必要な設定には compose.override.yaml ファイルを使用してください。Composeは compose.yaml と共にこれを自動的に読み込みます。