MCPInstall

compose

Docker Compose 编排

Installs
71
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/chaterm/terminal-skills --skill compose
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads compose automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Docker Compose 编排

概述

多容器编排、环境变量、网络配置等技能。

基础命令

# 启动服务
docker compose up
docker compose up -d                # 后台运行
docker compose up --build           # 重新构建

# 停止服务
docker compose down
docker compose down -v              # 同时删除卷
docker compose down --rmi all       # 同时删除镜像

# 查看状态
docker compose ps
docker compose ps -a

# 查看日志
docker compose logs
docker compose logs -f              # 实时跟踪
docker compose logs service_name

# 执行命令
docker compose exec service_name sh
docker compose run service_name command

# 重启服务
docker compose restart
docker compose restart service_name

# 扩缩容
docker compose up -d --scale web=3

配置文件

基础结构

# docker-compose.yml
version: "3.9"

services:
  web:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/share/nginx/html
    depends_on:
      - api

  api:
    build: ./api
    environment:
      - DATABASE_URL=postgres://db:5432/mydb
    depends_on:
      - db

  db:
    image: postgres:15
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: secret

volumes:
  db_data:

networks:
  default:
    driver: bridge

服务配置详解

build

services:
  app:
    # 简单形式
    build: ./app
    
    # 完整形式
    build:
      context: ./app
      dockerfile: Dockerfile.prod
      args:
        - VERSION=1.0
      target: production
      cache_from:
        - myapp:cache

ports

services:
  web:
    ports:
      - "80:80"                     # HOST:CONTAINER
      - "443:443"
      - "8080-8090:8080-8090"       # 端口范围
      - "127.0.0.1:3000:3000"       # 绑定特定 IP

volumes

services:
  app:
    volumes:
      # 命名卷
      - data:/var/lib/data
      # 绑定挂载
      - ./config:/etc/app/config:ro
      # 匿名卷
      - /var/lib/data

volumes:
  data:
    driver: local

environment

services:
  app:
    environment:
      - NODE_ENV=production
      - DATABASE_URL=postgres://localhost/db
    # 或使用映射形式
    environment:
      NODE_ENV: production
      DATABASE_URL: postgres://localhost/db
    # 从文件加载
    env_file:
      - .env
      - .env.local

depends_on

services:
  web:
    depends_on:
      - db
      - redis
    # 带条件
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started

healthcheck

services:
  web:
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

deploy(Swarm 模式)

services:
  web:
    deploy:
      replicas: 3
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
        reservations:
          cpus: '0.25'
          memory: 256M
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3

网络配置

自定义网络

services:
  frontend:
    networks:
      - frontend
  
  backend:
    networks:
      - frontend
      - backend
  
  db:
    networks:
      - backend

networks:
  frontend:
    driver: bridge
  backend:
    driver: bridge
    internal: true              # 内部网络,无外部访问

网络别名

services:
  db:
    networks:
      backend:
        aliases:
          - database
          - postgres

环境变量

.env 文件

# .env
POSTGRES_VERSION=15
POSTGRES_PASSWORD=secret
APP_PORT=3000
# docker-compose.yml
services:
  db:
    image: postgres:${POSTGRES_VERSION}
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
  
  app:
    ports:
      - "${APP_PORT}:3000"

多环境配置

# docker-compose.override.yml(开发环境,自动加载)
# docker-compose.prod.yml(生产环境)

# 使用多个配置文件
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# docker-compose.yml(基础配置)
services:
  app:
    image: myapp:latest

# docker-compose.override.yml(开发覆盖)
services:
  app:
    build: .
    volumes:
      - .:/app
    environment:
      - DEBUG=true

# docker-compose.prod.yml(生产覆盖)
services:
  app:
    restart: always
    environment:
      - DEBUG=false

常见场景

场景 1:Web 应用栈

version: "3.9"

services:
  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    depends_on:
      - app

  app:
    build: .
    environment:
      - DATABASE_URL=postgres://postgres:secret@db:5432/mydb
      - REDIS_URL=redis://redis:6379
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started

  db:
    image: postgres:15-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: mydb
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data

volumes:
  postgres_data:
  redis_data:

场景 2:开发环境热重载

version: "3.9"

services:
  app:
    build:
      context: .
      target: development
    volumes:
      - .:/app
      - /app/node_modules          # 排除 node_modules
    environment:
      - NODE_ENV=development
    command: npm run dev
    ports:
      - "3000:3000"

场景 3:数据库初始化

services:
  db:
    image: postgres:15
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
    environment:
      POSTGRES_PASSWORD: secret

场景 4:日志配置

services:
  app:
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

故障排查

# 查看配置
docker compose config

# 查看服务日志
docker compose logs service_name --tail=100

# 进入容器
docker compose exec service_name sh

# 查看网络
docker network ls
docker network inspect project_default

# 重建服务
docker compose up -d --force-recreate service_name
问题排查方法
服务无法启动docker compose logs, 检查依赖
网络不通检查网络配置、服务名
卷挂载问题检查路径、权限
环境变量未生效docker compose config 验证

FAQ

What does the compose skill do?

Docker Compose 编排

How do I install compose?

Run npx skills add https://github.com/chaterm/terminal-skills --skill compose in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/compose/ (personal) or .claude/skills/compose/ (project).

Which AI agents can use compose?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is compose safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains compose?

It is published by chaterm in chaterm/terminal-skills. It has 71 recorded installs.

More from chaterm/terminal-skills

View all →

cron

chaterm/terminal-skills

定时任务管理

1.3K installs

system-admin

chaterm/terminal-skills

Linux system administration and monitoring

DevOps & Cloud561 installs

systemd

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

253 installs

network-tools

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

217 installs

vpn

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

193 installs

ssh

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

147 installs

Popular devops & cloud skills

View category →

microsoft-foundry

microsoft/azure-skills

Build, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and resources end to end. USE FOR: foundry, azd ai agent, azd provision/deploy, hosted agent scaffold/develop/run/deploy/troubleshoot, prompt agent create, managed harness agent create, GitHub Copilot harness agent, create agent, update agent, add tool to agent, invoke agent, agent insights, evaluate agent, batch eval, continuous eval, continuous monitoring, agent CI/CD, optimize prompt, improve prompt, optimize agent instructions, Agent Optimizer scaffold, dataset curation from traces, deploy model, model fine-tuning (SFT/DPO/RFT), Foundry project, RBAC, role assignment, permissions, quota, capacity, region, deployment failure, AI Services, create Foundry resource, knowledge index, customize deployment, onboard, availability, training-data, grader, distillation, large file upload. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure

OfficialDevOps & Cloud579.1K installs

azure-diagnostics

microsoft/azure-skills

Debug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe triage. WHEN: debug production issues, troubleshoot app service, app service high CPU, app service deployment failure, troubleshoot container apps, container app 503 or target port mismatch, troubleshoot functions, function telemetry missing or stopped after a config/connection-string change, troubleshoot AKS, VM RDP, Linux SSH, VM black screen, can't connect to VM, reset VM password, NSG or firewall blocking, kubectl cannot connect, kube-system/CoreDNS failures, pod pending, crashloop, node not ready, upgrade failures, analyze logs, KQL, insights, image pull failures, cold start issues, health probe failures, resource health, root cause of errors, troubleshoot event hubs, troubleshoot service bus, messaging SDK error, AMQP connection failure, message lock lost, lock renewal during long-running processing, service bus dead letter.

OfficialDevOps & Cloud569.8K installs

azure-prepare

microsoft/azure-skills

Prepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Terraform), and Dockerfiles for the Azure Developer CLI (azd) workflow. USE ONLY when the user explicitly wants to use azd as the deployment tool, or the project already has an azure.yaml file. DO NOT USE FOR: non-azd deployments, Python App Service code-only deploys (use python-appservice-deploy), or cross-cloud migration (use azure-cloud-migrate). WHEN: prepare app for azd, create azure.yaml, set up azd infrastructure, modernize app for Azure with azd, deploy with azd, function app, timer trigger, service bus trigger, event-driven function, managed identity, generate Bicep, generate Terraform, create and deploy to Azure.

OfficialDevOps & Cloud569K installs

azure-ai

microsoft/azure-skills

Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.

OfficialDevOps & Cloud568.8K installs

azure-deploy

microsoft/azure-skills

Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: "run azd up", "run azd deploy", "execute deployment", "push to production", "push to cloud", "go live", "ship it", "bicep deploy", "terraform apply", "publish to Azure", "launch on Azure". DO NOT USE WHEN: "create and deploy", "build and deploy", "create a new app", "set up infrastructure", "create and deploy to Azure using Terraform" — use azure-prepare for these.

OfficialDevOps & Cloud568.6K installs

azure-validate

microsoft/azure-skills

Pre-deployment validation for Azure readiness. Run deep checks on configuration, infrastructure (Bicep or Terraform), RBAC role assignments, managed identity permissions, and prerequisites before deploying. WHEN: validate my app, check deployment readiness, run preflight checks, verify configuration, check if ready to deploy, validate azure.yaml, validate Bicep, test before deploying, troubleshoot deployment errors, validate Azure Functions, validate function app, validate serverless deployment, verify RBAC roles, check role assignments, review managed identity permissions, what-if analysis, validate Container Apps deployment.

OfficialDevOps & Cloud568K installs