yaml.parser.ParserError

ERROR: yaml.parser.ParserError: while parsing a block mapping in "./docker-compose.yml", line 15

在写docker-compose.yml文件

version: '2'
services:

  # PostgreSQL

  mydb:

    image: postgres:10

    ports:

      - "5432:5432"

    environment:

      - POSTGRES_DB=postgres

      - POSTGRES_USER=odoo

      - POSTGRES_PASSWORD=odoo

    volumes:

      - odoo-db-data:/var/lib/postgresql/data


  # Odoo web

  web:

   build:

      context: ../odoo_demo

      dockerfile: Dockerfile

    hostname: web

    command: ./docker_run_web.sh

    volumes:

      - ../odoo_demo:/app  # mount current directory inside container

    - odoo-web-data:/app/odoo-web-db # 把此路径/app/odoo-ee-web-db配置到odoo conf data_dir参数中

   ports:

     - "8069:8069"

    # set up links so that web knows about db, rabbit and redis

    depends_on:

      - mydb


volumes:

 odoo-web-data:

 odoo-db-data:

文件写完运行

docker-compose up -d

报错:

ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 15, column 5
expected <block end>, but found '<block mapping start>'
in "./docker-compose.yml", line 25, column 4

查看发现问题(vim)

  • 原因文件内块对齐有问题,使用notepad++打开查看如下:

      volumes:
    
      	  - ../odoo_demo:/app  # mount current directory inside container
    
      	- odoo-web-data:/app/odoo-web-db # 把此路径/app/odoo-ee-web-db配置到odoo conf data_dir参数中
    

解决办法:

  • 在下面这句话前面添加两个空格,使他能和上面保持对其

      - odoo-web-data:/app/odoo-web-db # 把此路径/app/odoo-ee-web-db配置到odoo conf data_dir参数中
    
posted @ 2019-03-18 14:08  玄机  阅读(8445)  评论(0编辑  收藏  举报