如何修复docker-compose.yml? – 期待,但发现”

前端之家收集整理的这篇文章主要介绍了如何修复docker-compose.yml? – 期待,但发现”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

我的yml文件中似乎存在缩进问题.我在这里读了一些其他问题,并尝试了各种缩进方案.我仍然无法让它工作.在发布此问题之前,我故意删除了env名称/ pws.

version: '2'
  ghost:
    image: ghost:latest
    container_name: ghost-blog  #Specify a custom container name,rather than a generated default name.
    environment:
      - NODE_ENV=production
      - MysqL_DATABASE=db-name # Change {{db-name}}
      - MysqL_USER=user # Change {{username}}
      - MysqL_PASSWORD=pass # Change {{db-password}}
      # - "MAILGUN_USER={{mailgun-user}}" # Change {{mailgun-user}}
      # - "MAILGUN_PASSWORD={{mailgun-password}}" # Change {{mailgun-password}}
    volumes:
      - ./ghost:/var/lib/ghost # persist the data
    ports:
      - 2368:2368
    depends_on:
      - MysqL # ensure that the database will start first
    restart: always

  MysqL:
    image: MysqL:latest
    container_name: ghost-db
    environment:
      - MysqL_DATABASE=dbname # Change {{db-name}}
      - MysqL_ROOT_PASSWORD=db-pass # Change {{root-password}}
      - MysqL_USER=user # Change {{username}}
      - MysqL_PASSWORD=sq-pass # Change {{db-password}}
    volumes:
      - ./db:/var/lib/MysqL
    restart: always
最佳答案
将来,您可以使用此website来检查它有什么问题,然后随时修复它.

编辑:

所以你的docker-compose文件遇到的问题如下:

>您没有添加服务:版本和之后
>如果您想要最新的图像,则不必传递:latest标记,当您需要特定版本的图像时,您将传递标记,并且在“”之间完成

至于代码,它应该如下:

version: '2'

services:
      ghost:
        image: ghost
        container_name: ghost-blog
        environment:
          - NODE_ENV=production
          - MysqL_DATABASE=db-name
          - MysqL_USER=user
          - MysqL_PASSWORD=pass
      #   - "MAILGUN_USER={{mailgun-user}}"
      #   - "MAILGUN_PASSWORD={{mailgun-password}}" # Change {{mailgun-password}}
        volumes:
         - ./ghost:/var/lib/ghost # persist the data
        ports:
          - 2368:2368
        depends_on:
          - MysqL # ensure that the database will always start first
        restart: always

      MysqL:
        image: MysqL
        container_name: ghost-db
        environment:
          - MysqL_DATABASE=dbname # Change {{db-name}}
          - MysqL_ROOT_PASSWORD=db-pass # Change {{root-password}}
          - MysqL_USER=user # Change {{username}}
          - MysqL_PASSWORD=sq-pass # Change {{db-password}}
        volumes:
          - ./db:/var/lib/MysqL
        restart: always

猜你在找的Docker相关文章