5

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.

Sameer Manek
  • 97
  • 1
  • 1
  • 7

1 Answers1

10

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
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • it is yielding the same error. i changed that for all the volume commands. does setting my vscode to use spaces instead of tabs has to do something with this? – Sameer Manek Jan 05 '20 at 19:17
  • @SameerManek mixing spaces and tabs in a whitespace delimited file is going to break things. Yaml files should only use spaces. https://stackoverflow.com/q/19975954/596285 – BMitch Jan 05 '20 at 21:43