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.

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

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?
@SameerManek mixing spaces and tabs in a whitespace delimited file is going to break things. Yaml files should only use spaces. stackoverflow.com/q/19975954/596285

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.