Token导航 LogoToken导航

Agent Skill · 开发

docker-compose(Docker Compose 编排)

用于辅助云资源、部署、容器、基础设施和运维自动化任务。它适合让 Agent 检查配置、整理部署步骤、分析资源状态、生成排障思路或辅助云服务接入。使用时需要明确目标环境、账号权限、区域和资源组,区分本地测试与生产操作;涉及删除资源、重启服务、修改网络或权限配置时,应先确认影响范围。

docker-compose 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描有未通过项,按安装量在开发类的 21,746 个 Skill 里排第 10,176。

总安装 2,371周安装 95GitHub Stars 25下载 768核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:docker-compose(Docker Compose 编排)
来源仓库:https://github.com/oimiragieo/agent-studio
仓库路径:skills/docker-compose
安装命令:
npx skills add https://github.com/oimiragieo/agent-studio --skill docker-compose
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/oimiragieo/agent-studio --skill docker-compose

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

docker-compose 用于辅助云资源、部署、容器、基础设施和运维自动化任务。适用于容器编排、部署管理和基础设施运维等场景。通过 GitHub 仓库安装,使用 npx skills add 命令添加技能。

使用时需要明确目标环境、账号权限、区域和资源组,区分本地测试与生产操作;涉及删除资源、重启服务、修改网络或权限配置时,应先确认影响范围。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/docker-compose

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/oimiragieo/agent-studio --skill docker-compose;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

docker-compose 怎么安装?

在终端执行 npx skills add https://github.com/oimiragieo/agent-studio --skill docker-compose。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

docker-compose 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

docker-compose 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

docker-compose 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

docker-compose 用的人多吗?

公开数据是累计安装 2,371 次,近一周安装 95 次,下载 768 次,GitHub 25 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

docker-compose 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
docker-compose

Docker Compose 编排 · 本页

2,37125接触敏感数据未明确未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Docker Compose Skill

Installation

The skill invokes docker compose. Easiest: install Docker Desktop (includes Docker Engine + Compose):

Verify: docker compose version

Cheat Sheet & Best Practices

Commands: docker compose up -d / down; docker compose ps / logs -f <service>; docker compose exec <service> sh; docker compose build --no-cache; docker compose -f compose.prod.yaml config — validate.

YAML: Use named volumes for DBs (postgres_data:/var/lib/postgresql/data). Use healthchecks (healthcheck: with test, interval, timeout, retries). One network default; reference services by name (e.g. http://api:3000). Use env_file or environment; keep secrets in secrets:.

Hacks: -f compose.yaml -f override.yaml merges files (later overrides). Use --project-name for isolation. Prefer build: context:. dockerfile: Dockerfile for dev; pin image tags in prod. Run docker compose config before up to catch errors.

Certifications & Training

Docker Certified Associate (DCA): Orchestration 25%, Image/Registry 20%, Install/Config 15%, Networking 15%, Security 15%, Storage 10%. Free: Official DCA Study Guide, Coursera DCA Prep (audit). Skill data: Compose YAML (services, volumes, networks, healthchecks), CLI (up/down/ps/logs/exec).

Hooks & Workflows

Suggested hooks: Pre-up: docker compose config (validate). Post-down: optional cleanup. Use when devops or devops-troubleshooter is routed.

Workflows: Use with devops (primary), devops-troubleshooter (primary). Flow: validate compose → up/down/exec per task. See operations/incident-response for container debugging.

Overview

This skill provides comprehensive Docker Compose management, enabling AI agents to orchestrate multi-container applications, manage services, inspect logs, and troubleshoot containerized environments with progressive disclosure for optimal context usage.

Context Savings: ~92% reduction

  • MCP Mode: ~25,000 tokens always loaded (multiple tools + schemas)
  • Skill Mode: ~700 tokens metadata + on-demand loading

When to Use

  • Managing local development environments
  • Orchestrating multi-container applications
  • Debugging service connectivity and networking
  • Monitoring container logs and health
  • Building and updating service images
  • Testing containerized application stacks
  • Troubleshooting service failures
  • Managing application lifecycle (start, stop, restart)

Requirements

  • Docker Engine installed and running
  • Docker Compose V2 (docker compose plugin — V1 docker-compose is end-of-life)
  • Valid compose.yaml (preferred) or compose.yml / docker-compose.yml in project
  • Appropriate permissions for Docker socket access

Quick Reference

# List running services
docker compose ps

# View service logs
docker compose logs <service>

# Start services
docker compose up -d

# Stop services
docker compose down

# Rebuild services
docker compose build

# Execute command in container
docker compose exec <service> <command>

# Live development reloading (Compose Watch)
docker compose watch

# Start with a profile active
docker compose --profile debug up -d

# Validate merged config
docker compose config

2026 Feature Highlights

compose.yaml — Canonical Filename

Docker Compose V2 prefers compose.yaml (and compose.yml) over the legacy docker-compose.yml. The version: top-level field is deprecated and should be omitted entirely in new files.

# compose.yaml  (preferred — no version: field needed)
services:
  web:
    build: .
    ports:
      - '8080:80'
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_PASSWORD: example
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Compose Watch — Live Development Reloading

Compose Watch (GA as of Compose 2.22+) replaces the manual rebuild-restart cycle during development. Configure a develop.watch block per service. Three actions are available:

ActionBehavior
syncInstantly copies changed files into the running container
rebuildTriggers docker compose build + recreates the container
sync+restartSyncs files then restarts the container process (no full rebuild)
services:
  api:
    build: .
    ports:
      - '3000:3000'
    develop:
      watch:
        # Sync source instantly — no rebuild needed for interpreted code
        - action: sync
          path: ./src
          target: /app/src
          ignore:
            - node_modules/
        # Rebuild when dependency manifest changes
        - action: rebuild
          path: package.json
        # Restart only when config changes
        - action: sync+restart
          path: ./config
          target: /app/config

Start with:

# Watch mode (keeps output in foreground)
docker compose watch

# Or combined with up
docker compose up --watch

When to use each action:

  • sync — interpreted languages (Node.js, Python, Ruby) where the runtime picks up changes
  • sync+restart — config or template files that require a process restart but not a full rebuild
  • rebuild — dependency manifest changes (package.json, requirements.txt, go.mod)

Profiles — Environment-Specific Services

Profiles allow a single compose.yaml to serve multiple environments. Services without a profile always start. Services with profiles only start when that profile is activated.

services:
  # Always starts — no profile
  api:
    build: .
    ports:
      - '3000:3000'
    depends_on:
      db:
        condition: service_healthy

  db:
    image: postgres:16-alpine
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 5s
      timeout: 3s
      retries: 5
    volumes:
      - db_data:/var/lib/postgresql/data

  # Only with --profile debug
  pgadmin:
    image: dpage/pgadmin4:latest
    profiles: ['debug']
    ports:
      - '5050:80'
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@admin.com
      PGADMIN_DEFAULT_PASSWORD: admin

  # Only with --profile monitoring
  prometheus:
    image: prom/prometheus:latest
    profiles: ['monitoring']
    ports:
      - '9090:9090'

  grafana:
    image: grafana/grafana:latest
    profiles: ['monitoring']
    ports:
      - '3001:3000'

volumes:
  db_data:
# Default: api + db only
docker compose up -d

# Debug: api + db + pgadmin
docker compose --profile debug up -d

# Monitoring: api + db + prometheus + grafana
docker compose --profile monitoring up -d

# Multiple profiles
docker compose --profile debug --profile monitoring up -d

# Via environment variable
COMPOSE_PROFILES=debug,monitoring docker compose up -d

Profile naming rules: [a-zA-Z0-9][a-zA-Z0-9_.-]+ — lowercase kebab-case recommended.

Include — Composable Configs

The include top-level key (introduced in Compose 2.20) allows you to split large compose files into modular, team-owned pieces. Each included file is loaded with its own project directory context, resolving relative paths correctly.

# compose.yaml (root — application layer)
include:
  - ./infra/compose.yaml # DB, Redis, message broker
  - ./monitoring/compose.yaml # Prometheus, Grafana

services:
  api:
    build: .
    depends_on:
      - db # defined in infra/compose.yaml
      - redis # defined in infra/compose.yaml
# infra/compose.yaml (infrastructure layer — owned by platform team)
services:
  db:
    image: postgres:16-alpine
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 5s
      timeout: 3s
      retries: 5
    volumes:
      - db_data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 5s
      timeout: 3s
      retries: 5

volumes:
  db_data:

include is recursive — included files can themselves include other files. Conflicts between resource names cause an error (no silent merging).

Healthcheck Best Practices

Always define healthchecks on stateful services so that depends_on: condition: service_healthy works correctly. Without healthchecks, dependent services may start before their dependency is ready.

services:
  db:
    image: postgres:16-alpine
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-postgres}']
      interval: 10s # How often to check
      timeout: 5s # Time to wait for response
      retries: 5 # Failures before marking unhealthy
      start_period: 30s # Grace period during container startup

  redis:
    image: redis:7-alpine
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 10s
      timeout: 3s
      retries: 3

  api:
    build: .
    depends_on:
      db:
        condition: service_healthy # waits until db passes healthcheck
      redis:
        condition: service_healthy

Healthcheck guidelines:

  • Use CMD (array form) not CMD-SHELL (string form) where possible — avoids shell injection risk
  • Use CMD-SHELL only when you need shell features (pg_isready, curl -f, etc.)
  • Set start_period for services with slow startup (JVM apps, first-run migrations)
  • Avoid curl in Alpine-based images unless explicitly installed; prefer wget -q --spider or native checks
  • For HTTP services: test: ["CMD-SHELL", "wget -q --spider http://localhost:3000/health || exit 1"]

Multi-Stage Build Pattern

Use multi-stage Dockerfiles to keep production images minimal and secure. Reference the specific build stage in compose.yaml for development.

# Dockerfile
# Stage 1: deps — install dependencies
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci

# Stage 2: builder — compile/transpile
FROM deps AS builder
COPY . .
RUN npm run build

# Stage 3: runner — minimal production image
FROM node:20-alpine AS runner
RUN addgroup -g 1001 -S appgroup && adduser -S -u 1001 -G appgroup appuser
WORKDIR /app
COPY --from=builder --chown=appuser:appgroup /app/dist ./dist
COPY --from=deps    --chown=appuser:appgroup /app/node_modules ./node_modules
USER appuser
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
  CMD wget -q --spider http://localhost:3000/health || exit 1
CMD ["node", "dist/index.js"]
# compose.yaml — dev targets the builder stage for faster iteration
services:
  api:
    build:
      context: .
      dockerfile: Dockerfile
      target: builder # Stop at builder stage in dev (includes devDeps)
    develop:
      watch:
        - action: sync
          path: ./src
          target: /app/src
          ignore:
            - node_modules/
        - action: rebuild
          path: package.json
# compose.prod.yaml — production uses the full runner stage
services:
  api:
    build:
      context: .
      dockerfile: Dockerfile
      target: runner # Minimal, non-root production image
    restart: unless-stopped

Resource Limits (Best Practice)

Always define resource limits to prevent container resource exhaustion:

services:
  api:
    image: myapp:latest
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 512M
        reservations:
          cpus: '0.25'
          memory: 128M
    restart: unless-stopped

Tools

The skill provides 15 tools across service management, monitoring, build operations, and troubleshooting categories:

Service Management (5 tools)

up

Start services defined in compose.yaml.

ParameterTypeDescriptionDefault
detachedbooleanRun in detached modetrue
buildbooleanBuild images before startingfalse
force_recreatebooleanRecreate containersfalse
project_namestringProject name overridedirectory name
servicesarraySpecific services to startall services
profilesarrayProfiles to activatenone
watchbooleanEnable Compose Watch modefalse

Example:

docker compose up -d
docker compose up --build
docker compose up web api
docker compose --profile debug up -d
docker compose up --watch

Safety: Requires confirmation for production environments.

down

Stop and remove containers, networks, volumes.

ParameterTypeDescriptionDefault
volumesbooleanRemove volumes (BLOCKED)false
remove_orphansbooleanRemove orphaned containersfalse
project_namestringProject name overridedirectory name

Example:

docker compose down
docker compose down --remove-orphans

Safety: Volume removal (-v flag) is BLOCKED by default. Requires confirmation.

start

Start existing containers without recreating them.

ParameterTypeDescriptionDefault
servicesarraySpecific services to startall services
project_namestringProject name overridedirectory name

Example:

docker compose start
docker compose start web
stop

Stop running containers without removing them.

ParameterTypeDescriptionDefault
timeoutnumberShutdown timeout (seconds)10
servicesarraySpecific services to stopall services
project_namestringProject name overridedirectory name

Example:

docker compose stop
docker compose stop --timeout 30 web
restart

Restart services (stop + start).

ParameterTypeDescriptionDefault
timeoutnumberShutdown timeout (seconds)10
servicesarraySpecific services to restartall services
project_namestringProject name overridedirectory name

Example:

docker compose restart
docker compose restart api

Status & Logs (3 tools)

ps

List containers with status information.

ParameterTypeDescriptionDefault
allbooleanShow all containers (including stopped)false
servicesarrayFilter by servicesall services
project_namestringProject name overridedirectory name

Example:

docker compose ps
docker compose ps --all

Output Fields: NAME, IMAGE, STATUS, PORTS

logs

View service logs with streaming support.

ParameterTypeDescriptionDefault
servicesarrayServices to view logs forall services
followbooleanFollow log output (stream)false
tailnumberNumber of lines to show100
timestampsbooleanShow timestampsfalse
sincestringShow logs since timestamp/durationnone
project_namestringProject name overridedirectory name

Example:

docker compose logs web
docker compose logs --tail 50 --follow api
docker compose logs --since "2026-01-01T10:00:00"

Note: Follow mode automatically terminates after 60 seconds to prevent indefinite streaming.

top

Display running processes in containers.

ParameterTypeDescriptionDefault
servicesarrayServices to inspectall services
project_namestringProject name overridedirectory name

Example:

docker compose top
docker compose top web

Output: Process list with PID, USER, TIME, COMMAND

Build & Images (3 tools)

build

Build or rebuild service images.

ParameterTypeDescriptionDefault
no_cachebooleanBuild without cachefalse
pullbooleanPull newer image versionsfalse
parallelbooleanBuild in paralleltrue
servicesarrayServices to buildall services
project_namestringProject name overridedirectory name

Example:

docker compose build
docker compose build --no-cache web
docker compose build --pull

Safety: Requires confirmation for no-cache builds (resource-intensive).

pull

Pull service images from registry.

ParameterTypeDescriptionDefault
ignore_pull_failuresbooleanContinue if pull failsfalse
servicesarrayServices to pullall services
project_namestringProject name overridedirectory name

Example:

docker compose pull
docker compose pull web api

Safety: Requires confirmation for production environments.

images

List images used by services.

ParameterTypeDescriptionDefault
project_namestringProject name overridedirectory name

Example:

docker compose images

Output Fields: CONTAINER, REPOSITORY, TAG, IMAGE ID, SIZE

Execution (2 tools)

exec

Execute a command in a running container.

ParameterTypeDescriptionRequired
servicestringService nameYes
commandarrayCommand to executeYes
userstringUser to execute ascontainer default
workdirstringWorking directorycontainer default
envobjectEnvironment variablesnone
project_namestringProject name overridedirectory name

Example:

docker compose exec web bash
docker compose exec -u root api ls -la /app
docker compose exec db psql -U postgres

Safety:

  • Destructive commands (rm -rf, dd, mkfs) are BLOCKED
  • Root user execution requires confirmation
  • Default timeout: 30 seconds
run

Run a one-off command in a new container.

ParameterTypeDescriptionDefault
servicestringService to runRequired
commandarrayCommand to executeservice default
rmbooleanRemove container after runtrue
no_depsbooleanDon't start linked servicesfalse
userstringUser to execute ascontainer default
envobjectEnvironment variablesnone
project_namestringProject name overridedirectory name

Example:

docker compose run --rm web npm test
docker compose run --no-deps api python manage.py migrate

Safety: Requires confirmation for commands that modify data.

Configuration (2 tools)

config

Validate and view the Compose file configuration.

ParameterTypeDescriptionDefault
resolve_image_digestsbooleanPin image tags to digestsfalse
no_interpolatebooleanDon't interpolate env varsfalse
project_namestringProject name overridedirectory name

Example:

docker compose config
docker compose config --resolve-image-digests

Output: Parsed and merged Compose configuration

port

Print the public port binding for a service port.

ParameterTypeDescriptionRequired
servicestringService nameYes
private_portnumberContainer portYes
protocolstringProtocol (tcp/udp)tcp
project_namestringProject name overridedirectory name

Example:

docker compose port web 80
docker compose port db 5432

Output: <host>:<port> binding

Common Workflows

Start a Development Environment

# 1. Validate configuration
docker compose config

# 2. Pull latest images
docker compose pull

# 3. Build custom images
docker compose build

# 4. Start services in detached mode
docker compose up -d

# 5. Check service status
docker compose ps

# 6. View logs
docker compose logs --tail 100

Live Development with Compose Watch

# 1. Ensure develop.watch blocks are configured in compose.yaml

# 2. Start with watch mode (foreground, shows sync events)
docker compose watch

# 3. Or start detached then watch
docker compose up -d
docker compose watch --no-up

Troubleshoot a Failing Service

# 1. Check container status
docker compose ps --all

# 2. View service logs
docker compose logs --tail 200 failing-service

# 3. Inspect running processes
docker compose top failing-service

# 4. Check configuration
docker compose config

# 5. Restart the service
docker compose restart failing-service

# 6. If needed, recreate container
docker compose up -d --force-recreate failing-service

Update Service Images

# 1. Pull latest images
docker compose pull

# 2. Stop services
docker compose down

# 3. Rebuild if using custom Dockerfiles
docker compose build --pull

# 4. Start with new images
docker compose up -d

# 5. Verify services
docker compose ps

Debug Service Connectivity

# 1. Check running services
docker compose ps

# 2. Inspect port mappings
docker compose port web 80
docker compose port api 3000

# 3. Exec into container
docker compose exec web sh

# 4. Test connectivity (from inside container)
docker compose exec web curl api:3000/health

# 5. Check logs for errors
docker compose logs web api

Clean Up Environment

# 1. Stop all services
docker compose down

# 2. Remove orphaned containers
docker compose down --remove-orphans

# 3. View images
docker compose images

# 4. Clean up (manual - volume removal BLOCKED)
# Volumes require manual cleanup with explicit confirmation

Use Profiles for Environment-Specific Services

# Development: default services only
docker compose up -d

# Development + debug tools
docker compose --profile debug up -d

# Start monitoring stack
docker compose --profile monitoring up -d

# Via env var (useful in CI)
COMPOSE_PROFILES=monitoring docker compose up -d

# Stop and clean a specific profile
docker compose --profile debug down

Configuration

Environment Variables

VariableDescriptionDefault
COMPOSE_PROJECT_NAMEDefault project namedirectory name
COMPOSE_FILECompose file pathcompose.yaml
COMPOSE_PROFILESComma-separated active profiles(none)
COMPOSE_PATH_SEPARATORPath separator for multiple files: (Linux/Mac), ; (Windows)
DOCKER_HOSTDocker daemon socketunix:///var/run/docker.sock
COMPOSE_HTTP_TIMEOUTHTTP timeout for API calls60
COMPOSE_PARALLEL_LIMITMax parallel operationsunlimited

Setup

  1. Install Docker Engine: # macOS brew install --cask docker # Linux (Ubuntu/Debian) sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin # Windows # Download Docker Desktop from docker.com
  2. Verify Docker Compose: # Check Docker version docker --version # Check Compose version (must be V2, e.g. 2.24+) docker compose version
  3. Create compose.yaml (no version: field — V2 does not require it): services: web: build:. ports: - '8080:80' depends_on: db: condition: service_healthy db: image: postgres:16-alpine environment: POSTGRES_PASSWORD: example healthcheck: test: ['CMD-SHELL', 'pg_isready -U postgres'] interval: 10s timeout: 5s retries: 5
  4. Test the skill: docker compose config docker compose ps

Safety Features

Blocked Operations

The following operations are BLOCKED by default to prevent accidental data loss:

  • Volume removal: docker compose down -v (BLOCKED - requires manual confirmation)
  • Full cleanup: docker compose down -v --rmi all (BLOCKED - extremely destructive)
  • Destructive exec: rm -rf, dd, mkfs, sudo rm inside containers (BLOCKED)
  • Force removal: docker compose rm -f (BLOCKED - use stop then rm)

Confirmation Required

These operations require explicit confirmation:

  • Building with --no-cache (resource-intensive)
  • Pulling images in production environments
  • Starting services with --force-recreate
  • Executing commands as root user
  • Running commands that modify databases
  • Stopping services with very short timeouts

Auto-Terminating Operations

The following operations auto-terminate to prevent resource issues:

  • Log following (--follow): 60-second timeout
  • Service execution (exec): 30-second timeout
  • One-off commands (run): 60-second timeout

Error Handling

Common Errors:

ErrorCauseFix
docker: command not foundDocker not installedInstall Docker Engine
Cannot connect to Docker daemonDocker not runningStart Docker service
network... not foundNetwork cleanup issueRun docker compose down then up
port is already allocatedPort conflictChange port mapping or stop conflicting service
no configuration file providedMissing compose fileCreate compose.yaml
service... must be builtImage not builtRun docker compose build
service unhealthyHealthcheck failingCheck docker compose logs <service>
include path not foundMissing included fileVerify paths in include: block

Recovery:

  • Validate configuration: docker compose config
  • Check Docker status: docker info
  • View service logs: docker compose logs
  • Force recreate: docker compose up -d --force-recreate
  • Clean restart: docker compose down && docker compose up -d

Integration with Agents

This skill integrates with the following agents:

Primary Agents

  • devops: Local development, CI/CD integration, container orchestration
  • developer: Application development, testing, debugging

Secondary Agents

  • qa: Integration testing, test environment setup
  • incident-responder: Debugging production issues, service recovery
  • cloud-integrator: Cloud deployment, migration to Kubernetes
  • performance-engineer: Performance testing, resource optimization

Progressive Disclosure

The skill uses progressive disclosure to minimize context usage:

  1. Initial Load: Only metadata and tool names (~700 tokens)
  2. Tool Invocation: Specific tool schema loaded on-demand (~100-150 tokens)
  3. Result Streaming: Large outputs (logs) streamed incrementally
  4. Context Cleanup: Old results cleared after use

Context Optimization:

  • Use --tail to limit log output
  • Use service filters to target specific containers
  • Prefer ps over ps --all for active services only
  • Use --since for time-bounded log queries

Troubleshooting

Skill Issues

Docker Compose not found:

# Check Docker Compose version
docker compose version

# V1 (docker-compose) is end-of-life — upgrade to V2
# Docker Compose V2 is integrated into Docker CLI as a plugin

Permission denied:

# Add user to docker group (Linux)
sudo usermod -aG docker $USER
newgrp docker

# Verify permissions
docker ps

Compose file issues:

# Validate syntax
docker compose config

# Check for errors (quiet mode — exit code only)
docker compose config -q

# View resolved configuration
docker compose config --resolve-image-digests

Network issues:

# List networks
docker network ls

# Remove unused networks
docker network prune

# Recreate services
docker compose down
docker compose up -d

Healthcheck failures:

# Inspect healthcheck status
docker inspect <container_id> | grep -A 10 Health

# View healthcheck output
docker compose logs <service>

# Manually run the healthcheck command
docker compose exec <service> pg_isready -U postgres

Compose Watch not syncing:

# Verify develop.watch block is present in compose.yaml
docker compose config | grep -A 20 develop

# Ensure Compose version is 2.22+
docker compose version

# Watch requires build: attribute (not image: only)

Performance Considerations

  • Build caching: Use layer caching for faster builds; avoid --no-cache unless necessary
  • Multi-stage builds: Dramatically reduce production image size (often 80%+)
  • Parallel operations: Docker Compose V2 parallelizes by default; use COMPOSE_PARALLEL_LIMIT to control
  • Resource limits: Define CPU/memory limits in compose file to prevent resource exhaustion
  • Log rotation: Use logging drivers to prevent disk space issues
  • Volume cleanup: Regularly clean unused volumes (requires manual confirmation)
  • Compose Watch vs bind mounts: Prefer develop.watch for cross-platform development; bind mounts have I/O performance issues on macOS/Windows

Related

Sources

Related Skills

Iron Laws

  1. ALWAYS use docker compose (V2 plugin) — never use docker-compose (V1 standalone), which is deprecated and will be removed.
  2. NEVER include secrets or credentials directly in compose files or committed .env files — use external secret management or .env.example templates for documentation only.
  3. ALWAYS define health checks on services that other services depend on — without health checks, dependent services start before their dependencies are actually ready.
  4. NEVER expose a service port to the host unless it must be accessed from outside the compose network — unnecessary host port exposure increases attack surface.
  5. ALWAYS specify resource limits (CPU and memory) on services intended for production — unlimited containers can starve other services and crash the host.

Anti-Patterns

Anti-PatternWhy It FailsCorrect Approach
Using docker-compose V1 commandV1 is deprecated; missing V2 features (profiles, merge, watch) and will be removedUse docker compose (space, not hyphen); verify docker compose version
Hardcoded secrets in compose fileSecrets committed to git are permanently exposed in historyUse environment variable references (${SECRET}) loaded from untracked .env
No health checks on database/cache servicesApp containers start before DB is ready; causes startup race conditions and crashesAdd healthcheck: with appropriate test commands; use depends_on: condition: service_healthy
Exposing all ports to host (0.0.0.0)Services accessible from any network interface including public interfacesBind to 127.0.0.1 for dev; use internal networks for service-to-service communication
No restart policyContainers stay down after crash or host reboot in productionUse restart: unless-stopped for services that should auto-recover

Memory Protocol (MANDATORY)

Before starting: Read .claude/context/memory/learnings.md

After completing:

  • New pattern -> .claude/context/memory/learnings.md
  • Issue found -> .claude/context/memory/issues.md
  • Decision made -> .claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.

平台分布

Codex

38.03%
按下载量换算292

Claude

31.77%
按下载量换算244

Cursor

16.85%
按下载量换算129

Gemini CLI

8.37%
按下载量换算64

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

未通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills