./docker-compose.yml is invalid because: Unsupported config option for services.app: 'db'

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    db:
     image: 'yobasystems/alpine-mariadb:10.4.17-arm32v7'
     environment:
       MYSQL_ROOT_PASSWORD: 'npm'
       MYSQL_DATABASE: 'npm'
       MYSQL_USER: 'npm'
       MYSQL_PASSWORD: 'npm'
     volumes:
       - ./data/mysql:/var/lib/mysql

Can someone please help? I am getting an error of:

./docker-compose.yml is invalid because: Unsupported config option for services.app: ‘db’

After running the command " docker-compose up -d"

I am also running version 1.25.0 on my raspberry pi for self host. I put it on a yaml validator and no errors seem to show up.

pi@PiWarden:/opt/nginx $ docker-compose up -d

I edited your post. Please, use code block next time. Here is how you can format your post properly:

Because the yaml is valid, but the indentation level is wrong so the db service is not a service but an option of the “app” service. This should work:

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
  db:
    image: 'yobasystems/alpine-mariadb:10.4.17-arm32v7'
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql
1 Like

Thank you. I am still receiving an indentation error somewhere though. The error reads:

ERROR: yaml.parser.ParserError: while parsing a block mapping
  in "./docker-compose.yml", line 3, column 3
expected <block end>, but found '<block mapping start>'
  in "./docker-compose.yml", line 18, column 4
version: '3'
services:
 app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
   db:
     image: 'yobasystems/alpine-mariadb:10.4.17-arm32v7'
     environment:
       MYSQL_ROOT_PASSWORD: 'npm'
       MYSQL_DATABASE: 'npm'
       MYSQL_USER: 'npm'
       MYSQL_PASSWORD: 'npm'
     volumes:
       - ./data/mysql:/var/lib/mysql
I'm sorry, I hope I indented correctly this time on here. I am new to using this, so I just followed the instructions on how to code block. Unfortunately I tried putting it on a yaml validator or a few, but it still shows 18 on some and none on others.  

line 3: indentation with 1 space char instead of 2
line 17: indentation with 3 space char instead of 2

@rimlek already fixed those in his post.

You should consider using an editor that actually highlights yaml indentation problems like Visual Studio Code with the Indent-Rainbow extension to see those type of errors immediatly.

1 Like

Thank you guys for all the help. I figured it out and I thought I might share it with you guys as well. It turned out it wasn’t an indentation problem, but rather a syntax problem. Apparently on version 3, when we grab the nginx image, we don’t have to add the latest tag next to the image file because it will automatically grab the latest automatically. I removed it to see what happens, and it was able to run the command afterwards just fine. Thank youguys!

The error message is clearly a warning about indentation. As @meyay wrote, I have sent you a corrected yaml. The YAML that you quoted after that was wrong again. And the wrong line is in the third line exactly as it is in the error message.

It was always true, but that is not a syntax error. You can add the latest tag if you want to. So I guess you somehow fixed the indentation error while you deleted the tag.