SuperAPI AI 工具集

docker-syntax-compose-services

部署与运维

查看项目

更新于 10-15 22:18

技能介绍

用途:在编写 compose.yaml 服务定义、配置服务依赖、设置健康检查与资源限制时提供参考,减少常见配置错误。

主要能力:覆盖服务定义结构(image、build、command、entrypoint、ports、environment、volumes、depends_on、healthcheck、deploy、restart);镜像与构建配置(tag、digest、私有仓库、多阶段 target、build args、cache_from、secrets、platforms);命令与入口的字符串/列表形式;端口短语法与长语法对比;环境变量优先级与 env_file;卷的短/长语法(volume、bind、tmpfs);depends_on 的 service_started、service_healthy、service_completed_successfully 条件;健康检查模板与常见命令(PostgreSQL、MySQL、Redis、HTTP、TCP);deploy 资源限制与副本;重启策略;安全配置(read_only、user、cap_drop、cap_add、security_opt);profiles 与 extends;以及 container_name、hostname、platform、pull_policy、logging、labels、init、stop_grace_period 等属性。

关键用法与限制:依赖数据库时应使用 condition: service_healthy;不要对需扩缩容的服务设置 container_name;敏感值应使用 Docker secrets 或 .env 插值,避免硬编码;生产环境端口应绑定具体接口;生产服务应设置 resources.limits.memory 并配合 restart: unless-stopped;命名卷需在顶层 volumes 声明;重启策略 no 需加引号。资料还提供 references/attributes.md、references/examples.md、references/anti-patterns.md 及官方文档链接。具体安装命令与收费信息暂未提供。