Home > database >  Docker-Compose: service "xxx" depends on undefined service "xxx": invalid compos
Docker-Compose: service "xxx" depends on undefined service "xxx": invalid compos

Time:10-11

So I looked at this article: link

And I don't see the problem I made, so that's why I am asking.

The error I am getting is:

service "Appback" depends on undefined service -Sql-server: invalid compose project

And my docker-compose.yml file looks like this:

version: '3.8'
services:
  Sql-server:
    image: mysql:latest
    environment:
      MYSQL_DATABASE: *****
      MYSQL_USER: ****
      MYSQL_PASSWORD: *****
      MYSQL_ROOT_PASSWORD: *****
    ports:
      - 3306:3306
    expose:
      - 3306
    volumes:
      - db:/var/lib/mysql
    networks:
      - appnetwork
  Appback:
    build:
      context: ./AppBack
      dockerfile: Dockerfile
    ports:
      - 8080:8080
    depends_on:
      -Sql-server:
         condition: service_started
    networks:
      - appnetwork
  appfront:
    build:
      context: ./appfront
      dockerfile: Dockerfile
    ports:
      - 3000:3000
    depends_on:
      -Appback:
         condition: service_started
    networks:
      - appnetwork

volumes:
  db:

networks:
  appnetwork:
    driver: bridge

I don't see where the problem might be as I am also new to docker compose.

CodePudding user response:

You should separate the -Sql-server: with a space - Sql-server: from the first hyphen character.

I saw the same error when you have -Appback: in the next few lines.

  • Related