service ‘volumes’ must be a mapping not an array

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

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

问题

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

以下是我的Docker Compose文件:

version: '3'

services:
  # nginx
  nginx:
    build: ./nginx
    volumes:
      - ./site:/var/www/html
    ports:
      - '8080:80'
    depends_on:
      - php
  # database
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: bedrock123
      MYSQL_DATABASE: xyz
      MYSQL_USER: iamuser
      MYSQL_PASSWORD: iampass
    networks:
      - wpsite
      
  # php
  php:
    image: php:latest
    volumes:
      - ./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:

version: '3'

services:
  # nginx
  nginx:
    build : ./nginx
    volumes: 
      - ./site:/var/www/html
    ports:
      - '8080:80'
    depends_on:
      php
  # database
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: bedrock123
      MYSQL_DATABASE: xyz
      MYSQL_USER: iamuser
      MYSQL_PASSWORD: iampass
    networks:
      - wpsite
  
  # php
  php:
    image: php:latest
  volumes:
    - ./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.

  # php
  php:
    image: php:latest
    volumes:
      - ./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:

确定