Docker Community Forums

Share and learn in the Docker community.

Service 'context' must be a mapping not a string

Hi there I am trying to compose a docker-compose.yml file but i am getting the following error

ERROR: In file ‘./docker-compose.yml’, service ‘context’ must be a mapping not a string.

this is my docker-compose file

version: '3'

services:

#PHP Service

app:

build:

context: .

container_name: app

environment:

DB_HOST: db

DB_PASSWORD: your_mysql_root_password

DB_USERNAME: root

depends_on:

- db

ports:

- "8080:80"

volumes:

- ./:/var/www/html

#MySQL Service

db:

image: mysql:5.7.22

container_name: db

restart: unless-stopped

tty: true

ports:

- "3306:3306"

environment:

MYSQL_DATABASE: phpapp

MYSQL_ROOT_PASSWORD: your_mysql_root_password

volumes:

- dbdata:/var/lib/mysql

#Volumes

volumes:

dbdata:

driver: local

I think it’s just indentation :

version: ‘3’
services:
redis-server:
image: redis
node-app:
build: .
ports:
- “4081:8081”

yes it was indentation. thanks for your reply