准备
- 先使用
python
找一个闲置的网段
from IPy import IP
ip = IP("192.168.16.0/24")
a = [i for i in ip]
a,len(a)
- 配置
compose
services:
db:
....
networks:
dbnet:
ipv4_address: 192.168.16.4
....
networks:
dbnet:
# external:
ipam:
config:
- subnet: 192.168.16.0/24
gateway: 192.168.16.1
报错
Error response from daemon: Pool overlaps with other one on this address space
该报错一般有两个常见原因
- 1.是网络冲突
- 解决方案
docker network ls
docker inspect {network_name}
docker network rm {}
#删除没有在用的容器
docker container prune
#删除没有在用的网络
docker network prune
- 2.是CIDR书写错误
解决方案:执行python
检验CIDR