something in docker-compose.yml does not match any of the regexes: '^x-'?

Viewed 9623
--- 
db-server: 
  container_name: db-server
  environment: 
    - ACCEPT_EULA=Y
    - MSSQL_SA_PASSWORD=Bruce1234
    - MSSQL_TCP_PORT=1433
  image: "microsoft/mssql-server-linux:2017-latest"
  networks: 
    - localdev
  ports: 
    - "1400:1433"
networks: 
  localdev: 
    name: localdev
services: 
  main-api: 
    build: CryptoAPI/
    depends_on: 
      - db-server
    networks: 
      - localdev
    ports: 
      - "7000:80"
    restart: always
version: "3.8"

Any help is appreciated this is the precise error i get:

Powershell error image

What is exactly wrong, I have googled everything.

1 Answers

The question is getting old, but here is an answer for anyone else getting in the same situation.

The db-server is a container and therefore should be in the services block with the main-api, like this :

version: "3.8"
networks:
  localdev:
    name: localdev
services:
  main-api:
    build: CryptoAPI/
    depends_on:
      - db-server
    networks:
      - localdev
    ports:
      - "7000:80"
    restart: always
  db-server:
    container_name: db-server
    environment:
      - ACCEPT_EULA=Y
      - MSSQL_SA_PASSWORD=Bruce1234
      - MSSQL_TCP_PORT=1433
    image: "microsoft/mssql-server-linux:2017-latest"
    networks:
      - localdev
    ports:
      - "1400:1433"

The order of the services doesn't matter, you just need the depends_on as you figured out.

Related