ERROR: Service "xxx" uses an undefined network "xxx"

WhoAmI picture WhoAmI · Oct 1, 2018 · Viewed 13.4k times · Source

It keeps saying me that this network is undefined. ERROR: Service frontend-network uses an undefined network frontend-network However, I see that there is such network with docker network ls. What am I missing :( I need your help. I've read a lot about it google, but couldn't find the right solution.

version: "3.3"
    services:
      web:
        build: ./Docker
        container_name: apache
        ports:
        - "80:80"
        volumes:
        - /home/denis/public-html:/usr/local/apache2/htdocs/
        restart: always
        networks:
        - frontend
        labels:
        - webstack
      mara:
        image: mariadb:latest
        container_name: mara
        ports:
        - "3306:3306"
        volumes:
        - ~/MariyaDb:/var/lib/mysql
        depends_on:
        - "web"
        restart: always
        networks:
        - frontend
        labels:
        - webstack
        environment:
        - MYSQL_ROOT_PASSWORD=example
      adminer:
        image: adminer
        container_name: adminer
        ports:
        - "8080:8080"
        depends_on:
        - "mara"
        restart: always
        networks:
        - frontend-network
        labels:
        - webstack

Answer

takacsmark picture takacsmark · Oct 1, 2018

You need to add this network to the Compose file as external network like this:

networks:
  frontend-network:
    external: true

You can read about this in the docks here: https://docs.docker.com/compose/compose-file/#external-1.