Moby: docker-compose(版本 3):depends_on 包含无效类型,它应该是一个数组

创建于 2017-01-24  ·  13评论  ·  资料来源: moby/moby

描述

重现问题的步骤:
1.验证是否安装了docker-compose 1.10.0 (docker-compose --version)

  1. 验证您使用的是版本 3 文件格式
  2. 验证并查看撰写文件(docker-compose -f test.yml config)

描述您收到的结果:
我收到以下错误消息:错误:撰写文件“./test.yml”无效,因为:
services.web.depends_on 包含无效类型,它应该是一个数组

描述您期望的结果:
我应该得到 yml 文件的内容

您认为重要的其他信息(例如,问题仅偶尔发生):
如果您将版本更改为:2.1,则它可以工作。 问题只发生在版本:3

docker version

Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Wed Jan 18 16:20:26 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Wed Jan 18 16:20:26 2017
 OS/Arch:      linux/amd64
 Experimental: true

docker-compose version 1.10.0, build 4bd6f1a
docker-py version: 2.0.1
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

docker info

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 23
Server Version: 1.13.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.4-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952 GiB
Name: moby
ID: AYXL:LFCG:OTTZ:BU52:F6MK:ECNA:42QF:MUJU:4NES:AT5D:UWRK:YWVV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 16
 Goroutines: 26
 System Time: 2017-01-24T13:47:58.459866975Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Username: royeectu
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

其他环境详细信息(AWS、VirtualBox、物理等):
test.yml 文件的内容:

version: '3'
services:
  web:
    build: .
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
  redis:
    image: redis
  db:
    image: redis
    healthcheck:
      test: "exit 0"
arestack versio1.13

最有用的评论

到目前为止,v.3 中是否有任何depends_on“条件:service_healthy”检查?

所有13条评论

ping @dnephin

@royeectu看起来这个错误是在使用docker-compose ; 你能在 docker-compose 问题跟踪器中重新打开这个问题吗? https://github.com/docker/compose/issues

我认为这是正确的行为。 扩展的依赖字段仅添加到 v2.1 格式中。

depends_ondocker stack deploy一起使用时是空操作。 Swarm 模式服务在失败时会重新启动,因此没有理由延迟它们的启动。 即使他们失败了几次,他们最终也会恢复。

@dnephin

我认为这是正确的行为。 扩展的依赖字段仅添加到 v2.1 格式中。

https://docs.docker.com/compose/compose-file/#dependson

顶部的文档指出Compose file version 3 reference但它有示例

version: '2.1'
services:
  web:
    build: .
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
  redis:
    image: redis
  db:
    image: redis
    healthcheck:
      test: "exit 0"

虽然示例在顶部说version 2.1我理解它为you need to have at least version 2.1 。 该文档没有说 3.0 不再支持此功能。 也许添加此信息或删除扩展示例,因为我知道这在未来的版本中不会被支持?

谢谢,是的,我们需要在这里修复文档。 我们最近按版本拆分文档,似乎我们在拆分过程中错过了这一点。

我打开了#2278

有人知道是否应该使用推荐的替代品吗? 谢谢

到目前为止,v.3 中是否有任何depends_on“条件:service_healthy”检查?

任何新闻 ?

以下是如何在版本 3 https://docs.docker.com/compose/compose-file/#depends_on 中使用它的说明

version: '3'
services:
  web:
    build: .
    depends_on:
      - db
      - redis
  redis:
    image: redis
  db:
    image: postgres

条件不再受支持

完全放弃支持如何改进? 任何人都可以指出我做出决定的讨论吗?

@lifenautjoe请参阅https://github.com/moby/moby/issues/31333 (和 https://github.com/moby/moby/issues/31333#issuecomment-409143581)上的讨论。 对于 docker-compose (不是docker stack deploy ),我还在https://github.com/moby/moby/issues/31333#issuecomment -333265696 (有一个x-depends_on )中留下了一个建议

每次我需要在 docker-compose 中做某事时 -> 删除功能 -> 不做 -> 响应故意留空 -> 5 年后......

@Strandedpirate新功能正在走向http://compose-spec.io

此页面是否有帮助?
0 / 5 - 0 等级