Docker-Compose: Service xxx depends on service xxx which is undefined

16,632

No, it's not defined. You have overwritten one services with the other one.

You should fix the configuration:

version: '3.5'

services:
  apache:
    build: ./Docker
    image: apache:latest
    ports:
     - "80:80"
    restart: always
  db:
    image: mariadb:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
    depends_on:
    - "apache"
  adminer:
    image: adminer
    restart: always
    ports:
    - "8080:8080"
    depends_on:
    - "db"

networks:
      default:
        name: frontend-network
Share:
16,632
WhoAmI
Author by

WhoAmI

Updated on June 13, 2022

Comments

  • WhoAmI
    WhoAmI almost 2 years

    I'm having this error:

    ERROR: Service 'db' depends on service 'apache' which is undefined.

    Why is it saying that apache is undefined? I check the indentation. Should be the right one.

    version: '3.5'
    
    services:
      apache:
        build: ./Docker
        image: apache:latest
        ports:
         - "80:80"
        restart: always
    networks:
           default:
             name: frontend-network
    
    services:
      db:
        image: mariadb:latest
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: example
        depends_on:
        - "apache"
      adminer:
        image: adminer
        restart: always
        ports:
        - "8080:8080"
        depends_on:
        - "db"
    networks:
          default:
            name: frontend-network
    
  • Salma Gomaa
    Salma Gomaa over 3 years
    stackoverflow.com/a/38089080/1770571 For external networks