Reputation: 1133
It keeps saying to me that the network is undefined.
ERROR: Service
frontend-network
uses an undefined networkfrontend-network
However, I see that there is already such a 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
Upvotes: 71
Views: 87743
Reputation: 2573
setting the default network driver (on bridge) worked for me
https://docs.docker.com/compose/compose-file/compose-file-v3/#bridge
networks:
frontend-network:
driver: bridge
Upvotes: 8
Reputation: 521
Specify the type of driver for your network in your Docker compose file like this:
networks:
frontend-network:
driver: <driver-name>
Upvotes: 2
Reputation: 4431
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/compose-file-v3/#external-1.
Upvotes: 99
Reputation: 3973
You need to create a user-defined network with:
docker network create etl_dev
After that, make sure you added it to the yaml with top-level networks:
, which goes at the same level of services.
version: "3.9"
networks:
etl_dev:
external: true
services:
local_database:
image: postgres:12
networks:
- etl_dev
volumes:
- /home/local_postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_USER_FILE: /run/secrets/etl_pg_usr_v1
POSTGRES_PASSWORD_FILE: /run/secrets/etl_pg_pass_v1
If you are using swarm, make sure you add -d overlay
to the docker network create command. See Network docs.
Upvotes: 16