service ‘volumes’ must be a mapping not an array

huangapple go评论167阅读模式
英文:

docker-compose - service 'volumes' must be a mapping not an array

问题

在您将此问题标记为重复之前,请注意我已经查看了很多帖子,但没有一个能解决问题。

以下是我的Docker Compose文件:

  1. version: '3'
  2. services:
  3. # nginx
  4. nginx:
  5. build: ./nginx
  6. volumes:
  7. - ./site:/var/www/html
  8. ports:
  9. - '8080:80'
  10. depends_on:
  11. - php
  12. # database
  13. db:
  14. image: mysql:5.7
  15. volumes:
  16. - db_data:/var/lib/mysql
  17. restart: always
  18. environment:
  19. MYSQL_ROOT_PASSWORD: bedrock123
  20. MYSQL_DATABASE: xyz
  21. MYSQL_USER: iamuser
  22. MYSQL_PASSWORD: iampass
  23. networks:
  24. - wpsite
  25. # php
  26. php:
  27. image: php:latest
  28. volumes:
  29. - ./site:/var/www/html

我意识到可能存在缩进错误,但我已经检查过了,但似乎并没有解决问题。

英文:

before you mark this question as duplicate, I have looked in a lot of threads and none of them are solving the problem.

here is my docker compose file:

  1. version: '3'
  2. services:
  3. # nginx
  4. nginx:
  5. build : ./nginx
  6. volumes:
  7. - ./site:/var/www/html
  8. ports:
  9. - '8080:80'
  10. depends_on:
  11. php
  12. # database
  13. db:
  14. image: mysql:5.7
  15. volumes:
  16. - db_data:/var/lib/mysql
  17. restart: always
  18. environment:
  19. MYSQL_ROOT_PASSWORD: bedrock123
  20. MYSQL_DATABASE: xyz
  21. MYSQL_USER: iamuser
  22. MYSQL_PASSWORD: iampass
  23. networks:
  24. - wpsite
  25. # php
  26. php:
  27. image: php:latest
  28. volumes:
  29. - ./site:./var/www/html

I am aware of probable indentation faults, and I did check for them but that doesn't seem to solve the problem.

答案1

得分: 10

这是一个缩进问题。php容器的卷需要缩进。否则,卷会被视为另一个要运行的服务。

php

php:
image: php:latest
volumes:
- ./site:./var/www/html

英文:

It's an indentation problem. Volumes of the php container need to be indented. Otherwise, volumes is treated as another service to run.

  1. # php
  2. php:
  3. image: php:latest
  4. volumes:
  5. - ./site:./var/www/html

huangapple
  • 本文由 发表于 2020年1月6日 02:32:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/59602982.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定