简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM