서비스 연결, 헬스 체크, 개발용 오버라이드 설정을 포함하여 Docker Compose 구성을 생성, 검토 및 디버깅하기 위한 규칙을 제공합니다.
- GitHub 스타
- 626
- 파일
- 10
- 마지막 커밋
- 2026년 11월 10일
- 라이선스
- Apache-2.0
- 허용된 도구
- —
docker-compose-patterns skill은 무엇을 하나요?
docker-compose-patterns은(는) agent skill입니다. 서비스 연결, 헬스 체크, 개발용 오버라이드 설정을 포함하여 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 기반 이미지에 대한 healthcheck sidecar 구현과 같은 복잡한 시나리오에 대한 전문적인 가이드를 제공합니다. 또한 볼륨 관리, env_file을 통한 환경 변수 관리, Compose Watch를 사용한 개발 워크플로우에 대한 지침도 제공합니다. 사용자는 로그에 민감한 인터폴레이션된 자격 증명을 노출하지 않고 현재 프로젝트 구성을 검증하기 위해 검증 스크립트를 실행할 수도 있습니다.
agent가 수행할 수 있는 작업
- 1서비스 시작 의존성 구성데이터베이스 서비스가 완전히 정상 상태(healthy)가 된 후에만 의존성 애플리케이션 컨테이너가 시작되도록 설정합니다.
- 2보안 강화 이미지용 헬스 체크 구현distroless 이미지에서 실행되는 API를 위해 헬스 체크를 수행하는 sidecar 컨테이너를 생성합니다.
- 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"를 사용하여 애플리케이션의 네트워크 네임스페이스를 공유하는 healthcheck sidecar를 사용하십시오.
어떤 Docker Compose 명령어가 되돌릴 수 없는 데이터 손실을 초래할 수 있나요?
docker compose down -v, docker volume rm, docker compose rm -v와 같은 명령어는 데이터베이스 데이터가 포함된 이름 있는 볼륨 또는 익명 볼륨을 삭제할 수 있습니다.
메인 구성을 변경하지 않고 개발 전용 설정을 관리하려면 어떻게 해야 하나요?
바인드 마운트나 디버그 포트와 같은 개발 전용 설정에는 compose.override.yaml 파일을 사용하십시오. Compose는 compose.yaml과 함께 이 파일을 자동으로 로드합니다.