用途:把 Docker 容器以生产级方式部署,强调可观测性、资源限制与部署策略配置。
主要能力:
- 健康检查:Dockerfile 中 HEALTHCHECK,或 Compose 的 healthcheck(test、interval、timeout、retries、start_period)。
- 资源管理:deploy.resources 限制 cpus、memory,设置 reservations,并配置 restart_policy(condition、delay、max_attempts)。
- 日志:logging.driver 可选 json-file,可设 max-size、max-file、labels;参数支持 json-file/loki/elk。
- 监控:可集成 Prometheus + Grafana + cadvisor,或用 Datadog;Prometheus 通过 prometheus.yml 的 docker_sd_configs 抓取容器。
- 部署策略:滚动更新(update_config 的 parallelism、delay、failure_action、order 与 rollback_config)及蓝绿部署示例。
参数:monitoring(枚举,可选 prometheus/datadog,默认 prometheus)、logging(枚举,可选 json-file/loki/elk,默认 json-file)、replicas(数字,默认 1)。
使用方式:以 Skill("docker-production") 调用,并按需在 Dockerfile/Compose 中写入上述配置。常用诊断命令: docker logs --tail 100 <container> docker inspect --format='{{.State.Health.Status}}' <container> docker stats --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" docker inspect --format='{{.RestartCount}}' <container> docker events --filter 'container=<name>' --since 1h
常见错误处理:unhealthy 多为健康检查失败(检查端点、增大 start_period);OOMKilled 为内存超限(提高限制或优化);restart loop 多为应用崩溃(查日志、修复应用),必要时回滚。
适用场景:需要监控、日志、健康检查与资源约束的 Docker 生产部署及运维排障。
限制:具体定价、平台依赖、性能指标与完整安装步骤暂未提供;相关技能为 docker-debugging、docker-ci-cd、docker-security。