如何解决无效地址它不属于此网络的任何子网 net.yaml解决了!
每当我跑步时:
docker-compose -f net.yaml up -d
我收到以下错误:
Creating network "twisted_static-network" with the default driver.
Creating server ... error
ERROR: for server Cannot start service tcp_server: Invalid address 192.168.1.1: It
does not belong to any of this network's subnets
ERROR: for tcp_server Cannot start service tcp_server: Invalid address
192.168.1.1: It does not belong to any of this network's subnets
ERROR: Encountered errors while bringing up the project.
我试过了:
- 对于
prune
docker 网络, - 删除并重新安装docker,
- 更改了 ipv4 地址。
但问题永远不会改变。
net.yaml
version: '3'
services:
tcp_server:
image: twisted_tcp:1.0
container_name: server
environment:
- LOCAL_IP=192.168.1.1
ports:
- 5679:5678
privileged: true
volumes:
- ./twisted_server.py:/run/twisted_server.py
command: >
bash -c pip3 install twisted
&& "python3 twisted_server.py"
networks:
static-network:
ipv4_address: 192.168.1.1
tcp_client:
image: twisted_tcp:1.0
depends_on:
- tcp_server
container_name: client
environment:
- LOCAL_IP=192.168.1.2
ports:
- 5680:5678
privileged: true
volumes:
- ./twisted_client.py:/run/twisted_client.py
command: >
bash -c pip3 install twisted
&& "python3 twisted_client.py"
networks:
static-network:
ipv4_address: 192.168.1.2
networks:
static-network:
ipam:
config:
- subnet: 192.168.0.0/24
gateway: 192.168.0.1
解决方法
解决了!
问题最终是 -subnet
中的 net.yaml
- 我对此进行了更改:
-subnet: 192.168.0.0/24
- 为此:
-subnet: 192.168.0.0/16
然后就可以了!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。