Error services.db.environment must be a mapping

Hello,

I try to create a symfony project with docker; but I have this error: services.db.environment must be a mapping
My code file docker-compose.yml:

version: '3.8'

networks:
  myapp:

services:
  db:
    container_name: ${APP_NAME}-db
    image: 'mariadb:latest'
    restart: always
    ports:
      - 3306:3306
    volumes:
      - './.docker/mysql:/var/lib/mysql'
    environment:
      - MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
      - MYSQL_USER: ${MYSQL_USER}
      - MYSQL_PASSWORD: ${MYSQL_PASS}
      - MYSQL_DATABASE: ${MYSQL_DB}
    networks:
      - myapp

  php:
    container_name: ${APP_NAME}-php
    build:
      context: .
      dockerfile: ./docker/php
    volumes:
      - './:/code:delegated'
    environment:
      - APP_ENV=${APP_ENV}
      - APP_SECRET=${APP_SECRET}
    depends_on:
      - db
    networks:
      - myapp

  nginx:
    container_name: ${APP_NAME}-nginx
    image: 'nginx:latest'
    ports:
      - 8080:80
    expose:
      - 80
    volumes:
      - ./:/code:delegated
      - ./docker/nginx/conf.d:/etc/nginx/conf.d
    depends_on:
      - php
    networks:
      - myapp

  phpmyadmin:
    image: 'phpmyadmin/phpmyadmin:latest'
    container_name: ${APP_NAME}-phpmyadmin
    ports:
      - 8000:80
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
    networks:
      - myapp

At first sight, this is not an indentation problem. What did I forget?
Thank you

The below syntax is incorrect :

Remove the hyphens :

environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASS}
      MYSQL_DATABASE: ${MYSQL_DB}
1 Like