本文介绍了如何修复docker-compose.yml? -预期<块结束&gt ;,但发现'<块映射开始>'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


中找到了<块映射开始

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

It seems there is an indentation issue in my yml file. I read some other questions on here, and tried various indentation schemes. I still cannot get it to work. I purposely removed the env names/pws before posting this question.

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


推荐答案

将来,您可以使用此方法来检查问题所在,然后随时进行修复。

In the future, you could use this website to check what is wrong with it and then fix it on the go.

编辑:

因此,docker-compose文件遇到的问题如下:

So the problems you had with your docker-compose file were as follows:


  1. 您没有在版本和

  1. You didn't add services: after the version and

如果您想要最新的图像,则不必传递:latest 标记,当您想要特定版本的图像时,将传递该标记这是在

You don't have to pass the :latest tag if you want the latest image, you will pass the tag when you want a specific version of the image and that's done between " "






之间完成的应如下所示:


As for the code, it should be as follows:

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-compose.yml? -预期&lt;块结束&gt ;,但发现'&lt;块映射开始&gt;'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 13:54