docker compose file not working:replicas不允许使用其他属性副本

时间:2017-04-23 01:20:29

标签: docker docker-compose

docker version:17.03.1-ce

尝试从入门教程开始使用docker-compose.yml。

version: "3"
   services:
     web:
       image: tuhina/friendlyhello:2.0
     deploy:
       replicas: 5
       resources:
         limits:
           cpus: "0.1"
           memory: 50M
      restart_policy:
        condition: on-failure
      ports:
        - "80:80"
      networks:
        - webnet
    networks:
      webnet:

出现此错误:

replicas Additional property replicas is not allowed

我输错了什么?

感谢。

编辑:docker-compose版本1.11.2,build dfed245

1 个答案:

答案 0 :(得分:41)

缩进在docker-compose.yml中至关重要。你设置它的方式,"部署"是一项服务,不是故意的。部署部分旨在指定有关" web"应该部署服务。以下内容允许docker-compose updocker stack deploy web --compose-file docker-compose.yml成功为我运行:

version: "3"

services:
  web:
    image: tuhina/friendlyhello:2.0
    deploy:
      replicas: 5
      resources:
        limits:
          cpus: "0.1"
          memory: '50M'
      restart_policy:
        condition: on-failure
    ports:
      - "80:80"
    networks:
      - webnet

networks:
  webnet: