You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker Compose报错:services.worker.init需为布尔值及depends_on格式问题

问题解决思路

1. 修复services.worker.init must be a boolean错误

检查你的docker-compose.yml中worker服务的init字段:

  • 必须设置为布尔值true或false,不能用字符串格式(比如"true")或其他类型值。
  • 正确示例:
    services:
      worker:
        init: true
        # 其他配置项...
    

2. 修复services.worker.depends_on must be a list错误

depends_on必须是列表格式,即使只依赖单个服务也要用数组包裹。如果要使用condition条件,写法需符合Compose V2规范:

  • 错误写法(非列表结构):
    depends_on:
      app:
        condition: service_started
    
  • 正确写法(列表嵌套对象):
    depends_on:
      - app:
          condition: service_started
    
  • 若无需条件,直接写列表即可:
    depends_on:
      - app
      - database
    

3. 关于depends_on的condition支持

Docker 24.0.7对应的Compose V2完全支持depends_on的condition配置,常用条件包括:

  • service_started:依赖服务启动完成即可
  • service_healthy:依赖服务通过健康检查后才启动
  • service_completed_successfully:依赖服务运行完成且退出码为0

额外提醒

确保你使用的是Compose V2命令(docker compose up),而非旧版V1命令(docker-compose up)。Shopware生产镜像文档基于Compose V2编写,V1不支持部分新特性。

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 12:50:07