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

Docker Compose执行失败:Compose文件无效报错求助

Fixing the Invalid Compose File Error

The error you're seeing is because Docker Compose version 3 does not support the object syntax for depends_on (with condition keys). In version 3, the depends_on field expects a simple array of service names instead.

What's Wrong in Your Config

Your current depends_on section uses an object format that's incompatible with version 3:

depends_on:
  mongo:
    condition: service_started

Corrected Config

Change the depends_on section to an array of service names to resolve the validation error:

pisignage-server:
    image: pisignage/pisignage-server:latest
    restart: unless-stopped
    ports:
      - 3000:3000
    volumes:
      - media:/media
      - data:/data
    depends_on:
      - mongo  # This is the correct array syntax for version 3

Bonus: Waiting for MongoDB to Be Fully Ready

Note that depends_on only waits for the MongoDB container to start—it doesn't verify that the MongoDB service inside is fully ready to accept connections. If you need to ensure pisignage-server starts only after MongoDB is operational, you can use a newer Compose format (version 3.8+) with health checks:

  1. Update your Compose file version to 3.8:
version: '3.8'
  1. Add a health check to the mongo service:
mongo:
    image: mongo:4.2.8
    restart: unless-stopped
    ports:
      - 27017:27017
    volumes:
      - mongodb:/data/db
      - mongodb_config:/data/configdb
    healthcheck:
      test: ["CMD", "mongo", "--eval", "db.adminCommand('ping')"]
      interval: 10s
      timeout: 5s
      retries: 5
  1. Use conditional dependency syntax:
pisignage-server:
    # ... other config ...
    depends_on:
      mongo:
        condition: service_healthy

This ensures pisignage-server only starts once MongoDB passes its health check.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 14:43:09