← 返回
未分类 中文

Docker Compose Optimizer

Optimize Docker Compose configurations for development and production — audit services, networking, volumes, health checks, and resource management.
优化 Docker Compose 配置,适用于开发和生产环境——审计服务、网络、卷、健康检查和资源管理。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 301
下载
💾 1
安装
1
版本
#latest

概述

Docker Compose Optimizer

Analyze Docker Compose files for best practices, security, performance, and production readiness. Audit service configurations, networking, volume mounts, health checks, dependency management, and resource constraints.

Usage

"Optimize my docker-compose.yml"
"Check Docker Compose for security issues"
"Review my multi-service setup"
"Make my Compose config production-ready"

How It Works

1. Configuration Analysis

cat docker-compose.yml 2>/dev/null || cat docker-compose.yaml 2>/dev/null || cat compose.yml 2>/dev/null
ls docker-compose*.yml 2>/dev/null

2. Service Audit

  • Image pinning: using tagged versions (not latest)
  • Health checks defined for each service
  • Restart policies appropriate (unless-stopped for production)
  • Environment variables: secrets in .env file, not inline
  • Build context: .dockerignore configured?
  • Port mapping: unnecessary host port exposure

3. Networking

  • Custom network vs default bridge
  • Service discovery via DNS names
  • Unnecessary port exposure to host
  • Network isolation between service groups
  • External network connections

4. Volumes & Storage

  • Named volumes vs bind mounts (named for data persistence)
  • Bind mounts for development (hot reload)
  • Volume drivers for production (backup, replication)
  • Tmpfs for temporary/sensitive data
  • Proper volume cleanup strategy

5. Dependencies & Ordering

  • depends_on with health check conditions
  • Startup ordering for database → app → worker
  • Graceful shutdown (stop_grace_period)
  • Init containers pattern (using profiles)

6. Resource Management

  • Memory limits (mem_limit, memswap_limit)
  • CPU limits (cpus, cpu_shares)
  • Logging configuration (driver, max-size, max-file)
  • Ulimits for production services

7. Dev vs Production

  • Override files (docker-compose.override.yml for dev)
  • Profile-based service selection
  • Dev-only services (mailhog, adminer, pgadmin)
  • Production-only services (monitoring, logging)

Output

## Docker Compose Analysis

**Services:** 6 | **Networks:** 1 (default) | **Volumes:** 3

### 🔴 Issues (2)
1. **No health checks** — 4/6 services missing health checks
   `depends_on` without `condition: service_healthy` is unreliable
   → Add healthcheck to db, redis, api, worker

2. **Secrets in compose file** — DB password inline
   `POSTGRES_PASSWORD: mypassword123`
   → Move to .env file or Docker secrets

### 🟡 Improvements (4)
3. No memory limits on any service — risk of one service OOM-killing others
4. Using `latest` tag on redis and postgres images
5. Default bridge network — create custom network for service isolation
6. No logging limits — logs will grow unbounded

### ✅ Good Practices
- Named volumes for database persistence
- Restart policy set to `unless-stopped`
- Build context uses multi-stage Dockerfile
- Override file separates dev config

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-08 02:42 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 90 📥 30,947
ai-agent

Slack Messaging

charlie-morrison
Slack 消息—通过 CLI 和 API 发送消息、管理频道、上传文件、添加反应并自动化团队通知。
★ 0 📥 520
it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,913