错误:服务"xxx"使用未定义的网络"xxx" [英] ERROR: Service "xxx" uses an undefined network "xxx"
问题描述
我一直在说这个网络是不确定的.错误:服务 frontend-network
使用未定义的网络 frontend-network
但是,我看到docker network ls存在这样的网络.我想念的是什么:(我需要你的帮助.我已经在Google上阅读了很多有关它的内容,但是找不到正确的解决方案.
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
推荐答案
您需要将此网络作为外部网络添加到Compose文件中,如下所示:
You need to add this network to the Compose file as external network like this:
networks:
frontend-network:
external: true
您可以在此处的扩展坞中阅读以下内容: https://docs.docker.com/compose/compose-file/#external-1 .
You can read about this in the docks here: https://docs.docker.com/compose/compose-file/#external-1.
这篇关于错误:服务"xxx"使用未定义的网络"xxx"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!