泊坞窗撰写文件不起作用:副本不允许其他属性副本 [英] docker compose file not working: replicas Additional property replicas is not allowed

查看:84
本文介绍了泊坞窗撰写文件不起作用:副本不允许其他属性副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

docker版本:17.03.1-ce

docker version: 17.03.1-ce

尝试从入门教程中获取docker-compose.yml。

Trying to get the docker-compose.yml working from the getting started tutorials.

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,构建dfed245

edit: docker-compose version 1.11.2, build dfed245

推荐答案

缩进在docker-compose.yml中至关重要。设置方式,部署是一项服务,并非旨在提供。部署部分旨在指定有关应如何部署 Web服务的信息。以下允许 docker-compose up docker stack deploy web --compose-file docker-compose.yml 运行为我成功:

Indentation is critical in docker-compose.yml. The way you have it set up, "deploy" is a service, which is not intended. The deploy section is intended to specify information about how the "web" service should be deployed. The following allows docker-compose up and docker stack deploy web --compose-file docker-compose.yml to run successfully for me:

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:

这篇关于泊坞窗撰写文件不起作用:副本不允许其他属性副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆