【问题标题】:How do I fix the docker-compose.yml? expected <block end>, but found '<scalar>'如何修复 docker-compose.yml?预期 <block end>,但发现 '<scalar>'
【发布时间】:2020-07-15 02:50:35
【问题描述】:

如何修复 docker-compose.yml?预期,但发现''

错误:yaml.parser.ParserError: 在解析块集合时 在“testnode.yml”,第 11 行,第 7 列 expected &lt;block end&gt;, but found '&lt;scalar&gt;' 在“testnode.yml”,第 11 行,第 18 列

我该如何解决这个问题?

version: '3'

services:
  uip-dns:
    container_name: uip-dns
    working_dir: /build
    image: "alpine"
    ports:
      - "26668:26668"
    volumes:
      - {{build}}:/build:Z
    command: ./dns
    networks:
      nsb_net:
        ipv4_address: 192.167.233.2
  node:
    container_name: node
    image: "tendermint-nsb/node"
    ports:
      - "26656-26657:26656-26657"
    environment:
      - PORT=:27667
      - DB_DIR=./data100/
      - TCP_AD=tcp://0.0.0.0:27667
      - ID=100
      - LOG=${LOG:-tendermint.log}
      - UIP_CHAIN_DNS=http://uip-dns:26668
    volumes:
      - {{build}}:/tendermint:Z
    command: node --rpc.laddr=tcp://0.0.0.0:26657 --proxy_app=tcp://0.0.0.0:27667
    networks:
      nsb_net:
        ipv4_address: 192.167.233.233

networks:
  nsb_net:
   # external: true
   driver: bridge
   ipam:
     driver: default
     config:
     -
       subnet: 192.167.232.0/22

【问题讨论】:

    标签: docker docker-compose yaml


    【解决方案1】:

    {{build}} 对 docker-compose.yml 无效。这看起来像一个 golang 模板,通常会在将文件传递给 docker-compose 之前对其进行扩展。您需要将其替换为字符串或定义的变量。例如

    version: '3'
    
    services:
      uip-dns:
        container_name: uip-dns
        working_dir: /build
        image: "alpine"
        ports:
          - "26668:26668"
        volumes:
          - ${build_dir:-./build}:/build:Z
        command: ./dns
        networks:
          nsb_net:
            ipv4_address: 192.167.233.2
      node:
        container_name: node
        image: "tendermint-nsb/node"
        ports:
          - "26656-26657:26656-26657"
        environment:
          - PORT=:27667
          - DB_DIR=./data100/
          - TCP_AD=tcp://0.0.0.0:27667
          - ID=100
          - LOG=${LOG:-tendermint.log}
          - UIP_CHAIN_DNS=http://uip-dns:26668
        volumes:
          - ${build_dir:-./build}:/tendermint:Z
        command: node --rpc.laddr=tcp://0.0.0.0:26657 --proxy_app=tcp://0.0.0.0:27667
        networks:
          nsb_net:
            ipv4_address: 192.167.233.233
    
    networks:
      nsb_net:
       # external: true
       driver: bridge
       ipam:
         driver: default
         config:
         - subnet: 192.167.232.0/22
    

    我还强烈建议去掉子网和容器的所有固定 IP。这些破坏了可移植性,以及扩展、滚动更新和各种其他功能的能力。如果可能,请改用发布的端口和主机 IP 地址,或容器之间的 docker DNS (reference)。

    【讨论】:

      猜你喜欢
      • 2018-03-27
      • 2019-04-26
      • 2019-09-30
      • 1970-01-01
      • 2017-10-16
      • 2021-09-25
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      相关资源
      最近更新 更多