Commmand docker create network mynetwork
给了我以下错误回复:
Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
我已经搜索了此错误,但这些解决方案都不起作用:
docker network prune
没有任何区别。以下是有关我的服务器环境的一些信息。 OS:
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.3 (Final)
Release: 6.3
Codename: Final
内核:
Linux xxx.com 3.10.0_3-0-0-17 #181 SMP Thu Feb 8 16:34:08 CST 2018 x86_64 x86_64 x86_64 GNU/Linux
搬运工:
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.2
Git commit: 0520e24
Built: Wed Mar 21 23:05:52 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:14:54 2018
OS/Arch: linux/amd64
Experimental: false
执行docker network create
时来自Docker守护程序的日志输出:
time="2018-04-02T14:46:15.280752033+08:00" level=debug msg="Calling POST /v1.37/networks/create"
time="2018-04-02T14:46:15.280955481+08:00" level=debug msg="form data: {\"Attachable\":false,\"CheckDuplicate\":true,\"ConfigFrom\":null,\"ConfigOnly\":false,\"Driver\":\"bridge\",\"EnableIPv6\":false,\"IPAM\":{\"Config\":[],\"Driver\":\"default\",\"Options\":{}},\"Ingress\":false,\"Internal\":false,\"Labels\":{},\"Name\":\"abcd\",\"Options\":{},\"Scope\":\"\"}"
time="2018-04-02T14:46:15.281417190+08:00" level=debug msg="Allocating IPv4 pools for network abcd (0b9717a7272a4c8782c49fa566d7e6a06704c0d085e6389e942998fbe97462a6)"
time="2018-04-02T14:46:15.281444055+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.281485165+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.281508839+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.281710387+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.281736496+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.281750737+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.281845693+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.281870666+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.281884536+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.281978263+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282003622+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282017850+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282100720+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282126269+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282139742+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282231487+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282257877+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282271266+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282400372+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282428023+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282442208+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282535390+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282567708+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282581458+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282665177+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282693288+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282706401+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282801403+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282830506+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282843584+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282930538+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.282960034+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.282972907+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283059526+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.283088441+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283101529+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283189181+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.283224740+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283238227+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283332740+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.283365026+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283379846+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283460062+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.283491194+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283504728+08:00" level=debug msg="Received set for ordinal 65535, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283588953+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.283622415+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283643410+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283729518+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.283765598+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283780273+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283859445+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.283893519+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283909058+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.283993771+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284028573+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284041138+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284128998+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284170756+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284185810+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284263887+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284303373+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284316600+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284397202+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284436789+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284449960+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284526967+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284567439+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284580543+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284662281+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284703475+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284716169+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284794971+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284835314+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284848272+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284926857+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.284976293+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.284996202+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285094175+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.285155415+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285171491+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285267913+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.285314698+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285327856+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285419681+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.285463945+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285476909+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285565520+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.285614270+08:00" level=debug msg="Received set for ordinal 0, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285631714+08:00" level=debug msg="Received set for ordinal 4095, start 0, end 0, any false, release false, serial:false curr:0 \n"
time="2018-04-02T14:46:15.285716032+08:00" level=debug msg="RequestPool(LocalDefault, , , map[], false)"
time="2018-04-02T14:46:15.285760262+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.240.0/20)"
time="2018-04-02T14:46:15.285778212+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.224.0/20)"
time="2018-04-02T14:46:15.285790635+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.208.0/20)"
time="2018-04-02T14:46:15.285802203+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.192.0/20)"
time="2018-04-02T14:46:15.285813998+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.176.0/20)"
time="2018-04-02T14:46:15.285825543+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.160.0/20)"
time="2018-04-02T14:46:15.285836927+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.144.0/20)"
time="2018-04-02T14:46:15.285848868+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.128.0/20)"
time="2018-04-02T14:46:15.285860012+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.112.0/20)"
time="2018-04-02T14:46:15.285871053+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.80.0/20)"
time="2018-04-02T14:46:15.285882613+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.64.0/20)"
time="2018-04-02T14:46:15.285894331+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.48.0/20)"
time="2018-04-02T14:46:15.285906570+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.32.0/20)"
time="2018-04-02T14:46:15.285917790+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.16.0/20)"
time="2018-04-02T14:46:15.285930785+08:00" level=debug msg="ReleasePool(LocalDefault/192.168.0.0/20)"
time="2018-04-02T14:46:15.285942133+08:00" level=debug msg="ReleasePool(LocalDefault/172.31.0.0/16)"
time="2018-04-02T14:46:15.285953628+08:00" level=debug msg="ReleasePool(LocalDefault/172.30.0.0/16)"
time="2018-04-02T14:46:15.285965120+08:00" level=debug msg="ReleasePool(LocalDefault/172.29.0.0/16)"
time="2018-04-02T14:46:15.285975972+08:00" level=debug msg="ReleasePool(LocalDefault/172.28.0.0/16)"
time="2018-04-02T14:46:15.285986956+08:00" level=debug msg="ReleasePool(LocalDefault/172.27.0.0/16)"
time="2018-04-02T14:46:15.285997910+08:00" level=debug msg="ReleasePool(LocalDefault/172.26.0.0/16)"
time="2018-04-02T14:46:15.286015087+08:00" level=debug msg="ReleasePool(LocalDefault/172.25.0.0/16)"
time="2018-04-02T14:46:15.286026575+08:00" level=debug msg="ReleasePool(LocalDefault/172.24.0.0/16)"
time="2018-04-02T14:46:15.286037792+08:00" level=debug msg="ReleasePool(LocalDefault/172.23.0.0/16)"
time="2018-04-02T14:46:15.286049714+08:00" level=debug msg="ReleasePool(LocalDefault/172.22.0.0/16)"
time="2018-04-02T14:46:15.286063811+08:00" level=debug msg="ReleasePool(LocalDefault/172.21.0.0/16)"
time="2018-04-02T14:46:15.286076360+08:00" level=debug msg="ReleasePool(LocalDefault/172.20.0.0/16)"
time="2018-04-02T14:46:15.286087965+08:00" level=debug msg="ReleasePool(LocalDefault/172.19.0.0/16)"
time="2018-04-02T14:46:15.286099514+08:00" level=debug msg="ReleasePool(LocalDefault/172.18.0.0/16)"
time="2018-04-02T14:46:15.286110733+08:00" level=debug msg="ReleasePool(LocalDefault/172.17.0.0/16)"
感谢您的帮助!
答案 0 :(得分:1)
the defaults
的一部分错误是指docker使用的31 predetermined address ranges,除非您在运行命令时指定了--subnet
选项(在这种情况下错误会消失): / p>
$ docker network create abcd --subnet 172.17.0.0/16
Docker守护进程的日志输出表明,它实际上正在尝试分配这31个默认子网中的几乎每个子网。分配失败的可能只有两个原因。
如果您的DNS服务器属于该子网,则Docker将不会使用默认子网。显然,这不太可能成为问题,但是我们仍然可以通过配置一些(虚拟)名称服务器来重现您的错误,每个31个默认子网中的每个名称服务器:
$ cat /etc/resolv.conf
nameserver 172.17.0.1
nameserver 172.18.0.1
nameserver 172.19.0.1
nameserver 172.20.0.1
nameserver 172.21.0.1
nameserver 172.22.0.1
nameserver 172.23.0.1
nameserver 172.24.0.1
nameserver 172.25.0.1
nameserver 172.26.0.1
nameserver 172.27.0.1
nameserver 172.28.0.1
nameserver 172.29.0.1
nameserver 172.30.0.1
nameserver 172.31.0.1
nameserver 192.168.0.1
nameserver 192.168.16.1
nameserver 192.168.32.1
nameserver 192.168.48.1
nameserver 192.168.64.1
nameserver 192.168.80.1
nameserver 192.168.96.1
nameserver 192.168.112.1
nameserver 192.168.128.1
nameserver 192.168.144.1
nameserver 192.168.160.1
nameserver 192.168.176.1
nameserver 192.168.192.1
nameserver 192.168.208.1
nameserver 192.168.224.1
nameserver 192.168.240.1
$ docker network create abcd
Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
阅读此内容的Ubuntu用户可以使用/run/systemd/resolve/resolv.conf
做同样的事情。
Docker官方文档指向article(UPD:cached page)
默认情况下,网桥从172. [17-31] .0.0 / 16或192.168。[0-256] .0 / 20范围中分配了一个子网,该子网不与任何现有主机接口重叠。
这意味着,就像使用名称服务器一样,我们可以通过向我们的路由表中添加与所有31个默认子网匹配的一些(虚拟)路由来重现您的错误:
$ ip route add 172.16.0.0/12 dev lo
$ ip route add 192.168.0.0/16 dev lo
$ docker network create abcd
Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
在您的情况下,很可能需要分析ip route
的输出并考虑两个目的:
172.[17-31].0.0/16
或192.168.[0-256].0/20
冲突的不必要的路由--subnet
选项一起使用。如果您的主机已连接到Internet,则该范围应位于RFC-1918的专用网络10.0.0.0/8
,172.16.0.0/12
或192.168.0.0/16
内其余与OP无关,但可能对来自搜索的用户有所帮助
已设置选项--redirect-gateway def1
(或从VPN服务器推送),OpenVPN会将IP路由0.0.0.0/1
和128.0.0.0/1
添加到路由表中。而且,由于这两个子网与任何可能的子网重叠,因此会引起问题。
可以通过使用--redirect-gateway
(不带标志)选项来避免,(如果从VPN服务器推送了原始选项,请与--pull-filter ignore "redirect-gateway def1"
组合使用)。
(大致而言)相当于--subnet 172.17.0.0/16
中的docker-compose.yml
选项:
networks:
default:
ipam:
config:
- subnet: 172.17.0.0/16