docker-compose-setup by pluginagentmarketplace/custom-plugin-docker
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-docker --skill docker-compose-setup掌握 Docker Compose,用于具有服务依赖关系、健康检查和环境管理的多容器应用程序编排。
为开发和生产环境设计和配置 Docker Compose 文件,实现适当的服务编排。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| services | array | 否 | - | 要配置的服务列表 |
| environment | enum | 否 | dev | dev/staging/prod |
| include_monitoring | boolean | 否 | false | 添加监控服务 |
注意:version 字段已弃用。请直接从 开始。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
services:services:
frontend:
build:
context: ./frontend
target: production
ports:
- "80:80"
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
backend:
build: ./backend
expose:
- "3000"
environment:
DATABASE_URL: postgres://user:${DB_PASSWORD}@database:5432/app
depends_on:
database:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 5
database:
image: postgres:16-alpine
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
volumes:
db_data:
# docker-compose.yaml (基础)
services:
app:
image: myapp:latest
# docker-compose.override.yaml (开发环境 - 自动加载)
services:
app:
build: .
volumes:
- ./src:/app/src
environment:
- DEBUG=true
# docker-compose.prod.yaml (生产环境)
services:
app:
deploy:
replicas: 3
restart: always
# 开发环境 (自动加载覆盖文件)
docker compose up
# 生产环境
docker compose -f docker-compose.yaml -f docker-compose.prod.yaml up -d
# .env 文件 (自动加载)
DB_PASSWORD=secret123
APP_VERSION=1.2.3
# 在 compose 文件中使用
environment:
- DB_PASSWORD=${DB_PASSWORD}
- VERSION=${APP_VERSION:-latest} # 默认值
services:
app:
image: myapp
# 仅在使用 --profile debug 时启用
debugger:
image: debug-tools
profiles:
- debug
# 仅在使用 --profile testing 时启用
test-db:
image: postgres:alpine
profiles:
- testing
docker compose up # 仅 app 服务
docker compose --profile debug up # app + debugger 服务
# 启动服务
docker compose up -d
# 重新构建并启动
docker compose up -d --build
# 查看日志
docker compose logs -f backend
# 扩展服务实例数
docker compose up -d --scale backend=3
# 停止并清理
docker compose down -v
# 验证配置
docker compose config
| 错误 | 原因 | 解决方案 |
|---|---|---|
undefined service | 依赖服务缺失 | 定义服务 |
yaml syntax error | 缩进错误 | 修复 YAML |
port already in use | 端口冲突 | 更改端口 |
healthcheck failing | 服务未就绪 | 增加 start_period |
docker compose config 验证配置--no-deps 跳过依赖项启动docker compose configdocker compose pull# 检查健康状态
docker inspect --format='{{json .State.Health}}' <container>
# 查看健康日志
docker inspect --format='{{range .State.Health.Log}}{{.Output}}{{end}}' <container>
Skill("docker-compose-setup")
每周安装次数
109
代码仓库
GitHub 星标数
1
首次出现
2026年2月13日
安全审计
安装于
cursor107
github-copilot107
opencode107
gemini-cli106
codex106
amp106
Master Docker Compose for multi-container application orchestration with service dependencies, health checks, and environment management.
Design and configure Docker Compose files for development and production environments with proper service orchestration.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| services | array | No | - | List of services to configure |
| environment | enum | No | dev | dev/staging/prod |
| include_monitoring | boolean | No | false | Add monitoring services |
Note : The version field is deprecated. Start directly with services:.
services:
frontend:
build:
context: ./frontend
target: production
ports:
- "80:80"
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
backend:
build: ./backend
expose:
- "3000"
environment:
DATABASE_URL: postgres://user:${DB_PASSWORD}@database:5432/app
depends_on:
database:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 5
database:
image: postgres:16-alpine
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
volumes:
db_data:
# docker-compose.yaml (base)
services:
app:
image: myapp:latest
# docker-compose.override.yaml (dev - auto-loaded)
services:
app:
build: .
volumes:
- ./src:/app/src
environment:
- DEBUG=true
# docker-compose.prod.yaml (production)
services:
app:
deploy:
replicas: 3
restart: always
# Development (loads override automatically)
docker compose up
# Production
docker compose -f docker-compose.yaml -f docker-compose.prod.yaml up -d
# .env file (auto-loaded)
DB_PASSWORD=secret123
APP_VERSION=1.2.3
# Using in compose
environment:
- DB_PASSWORD=${DB_PASSWORD}
- VERSION=${APP_VERSION:-latest} # Default value
services:
app:
image: myapp
# Only with --profile debug
debugger:
image: debug-tools
profiles:
- debug
# Only with --profile testing
test-db:
image: postgres:alpine
profiles:
- testing
docker compose up # app only
docker compose --profile debug up # app + debugger
# Start services
docker compose up -d
# Rebuild and start
docker compose up -d --build
# View logs
docker compose logs -f backend
# Scale service
docker compose up -d --scale backend=3
# Stop and clean
docker compose down -v
# Validate config
docker compose config
| Error | Cause | Solution |
|---|---|---|
undefined service | Dependency missing | Define service |
yaml syntax error | Indentation | Fix YAML |
port already in use | Port conflict | Change port |
healthcheck failing | Service not ready | Increase start_period |
docker compose config--no-deps to skip dependenciesdocker compose configdocker compose pull# Check health status
docker inspect --format='{{json .State.Health}}' <container>
# View health logs
docker inspect --format='{{range .State.Health.Log}}{{.Output}}{{end}}' <container>
Skill("docker-compose-setup")
Weekly Installs
109
Repository
GitHub Stars
1
First Seen
Feb 13, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
cursor107
github-copilot107
opencode107
gemini-cli106
codex106
amp106
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
96,200 周安装
R包生命周期管理指南 - 使用lifecycle包进行函数弃用与版本控制
97 周安装
KimiXlsx:Python Excel自动化工具,openpyxl/pandas数据导出与KimiXlsx CLI验证
97 周安装
Google Maps API 技能 - 完整 REST API 客户端,支持地理编码、路线、地点等20+服务
97 周安装
市场广度分析工具 - 量化评分系统,评估股市健康状况与参与广度
97 周安装
Magento 2 代码审查专家:自动化分析、安全漏洞检测与性能优化
97 周安装
深色模式实现指南:CSS/Tailwind/React 主题切换与系统偏好检测
97 周安装