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

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

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

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

  1. version: '2'
  2. ghost:
  3. image: ghost:latest
  4. container_name: ghost-blog #Specify a custom container name,rather than a generated default name.
  5. environment:
  6. - NODE_ENV=production
  7. - MysqL_DATABASE=db-name # Change {{db-name}}
  8. - MysqL_USER=user # Change {{username}}
  9. - MysqL_PASSWORD=pass # Change {{db-password}}
  10. # - "MAILGUN_USER={{mailgun-user}}" # Change {{mailgun-user}}
  11. # - "MAILGUN_PASSWORD={{mailgun-password}}" # Change {{mailgun-password}}
  12. volumes:
  13. - ./ghost:/var/lib/ghost # persist the data
  14. ports:
  15. - 2368:2368
  16. depends_on:
  17. - MysqL # ensure that the database will start first
  18. restart: always
  19. MysqL:
  20. image: MysqL:latest
  21. container_name: ghost-db
  22. environment:
  23. - MysqL_DATABASE=dbname # Change {{db-name}}
  24. - MysqL_ROOT_PASSWORD=db-pass # Change {{root-password}}
  25. - MysqL_USER=user # Change {{username}}
  26. - MysqL_PASSWORD=sq-pass # Change {{db-password}}
  27. volumes:
  28. - ./db:/var/lib/MysqL
  29. restart: always
最佳答案
将来,您可以使用此website来检查它有什么问题,然后随时修复它.

编辑:

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

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

至于代码,它应该如下:

  1. version: '2'
  2. services:
  3. ghost:
  4. image: ghost
  5. container_name: ghost-blog
  6. environment:
  7. - NODE_ENV=production
  8. - MysqL_DATABASE=db-name
  9. - MysqL_USER=user
  10. - MysqL_PASSWORD=pass
  11. # - "MAILGUN_USER={{mailgun-user}}"
  12. # - "MAILGUN_PASSWORD={{mailgun-password}}" # Change {{mailgun-password}}
  13. volumes:
  14. - ./ghost:/var/lib/ghost # persist the data
  15. ports:
  16. - 2368:2368
  17. depends_on:
  18. - MysqL # ensure that the database will always start first
  19. restart: always
  20. MysqL:
  21. image: MysqL
  22. container_name: ghost-db
  23. environment:
  24. - MysqL_DATABASE=dbname # Change {{db-name}}
  25. - MysqL_ROOT_PASSWORD=db-pass # Change {{root-password}}
  26. - MysqL_USER=user # Change {{username}}
  27. - MysqL_PASSWORD=sq-pass # Change {{db-password}}
  28. volumes:
  29. - ./db:/var/lib/MysqL
  30. restart: always

猜你在找的Docker相关文章