docker 创建网络 failed to allocate gateway (): No address returned 解决办法
Posted 为何一再沦落
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker 创建网络 failed to allocate gateway (): No address returned 解决办法相关的知识,希望对你有一定的参考价值。
docker 容器创建网络时候遇到 failed to allocate gateway (): No address returned 错误。
Docker internal error: 500 Server Error for http+docker://localhost/v1.26/networks/create: Internal Server Error (“failed to allocate gateway (): No address returned”).
在openstack中创建网络之后,在创建子网的时候,如果不创建网关,虚拟机可以使用,但是容器在使用neutron创建的这个网络时候会报错,使用kuryr结合docker创建网络的时候,需要有网关。
提示错误如下:
2021-04-16 11:23:02.420 43223 ERROR zun.compute.manager [req-c0b4fca4-4865-4054-8108-791dddc237ea 89805c2a82ea4780a6335bb42fef17e5 74b67e24d3bf403d895025c63e0a31dc default - -] Error occurred while calling Docker create API: Docker internal error: 500 Server Error for http+docker://localhost/v1.26/networks/create: Internal Server Error (“failed to allocate gateway (): No address returned”).: zun.common.exception.DockerError: Docker internal error: 500 Server Error for http+docker://localhost/v1.26/networks/create: Internal Server Error (“failed to allocate gateway (): No address returned”).
2021-04-21 23:38:15.411 308243 DEBUG zun.network.kuryr_network [req-9d7cd349-c488-4d60-a2b5-d70d9577cf62 89805c2a82ea4780a6335bb42fef17e5 74b67e24d3bf403d895025c63e0a31dc default - -] Attempt (1) to create network: Network(created_at=<?>,id=<?>,name=‘3c3e041f-dd85-4602-9b03-ae3da6db254f’,network_id=<?>,neutron_net_id=3c3e041f-dd85-4602-9b03-ae3da6db254f,project_id=74b67e24d3bf403d895025c63e0a31dc,updated_at=<?>,user_id=‘89805c2a82ea4780a6335bb42fef17e5’,uuid=<?>) create_network /usr/local/lib/python3.6/site-packages/zun/network/kuryr_network.py:120
2021-04-21 23:38:15.418 308243 DEBUG zun.network.kuryr_network [req-9d7cd349-c488-4d60-a2b5-d70d9577cf62 89805c2a82ea4780a6335bb42fef17e5 74b67e24d3bf403d895025c63e0a31dc default - -] Calling docker.create_network to create network 3c3e041f-dd85-4602-9b03-ae3da6db254f, ipam_options ‘Driver’: ‘kuryr’, ‘Options’: ‘neutron.net.shared’: ‘False’, ‘neutron.subnet.uuid’: ‘d399795d-8969-4913-a4ad-1638737b1a8c’, ‘Config’: [‘Subnet’: ‘192.168.4.0/24’, ‘Gateway’: ‘192.168.4.1’], options ‘neutron.net.uuid’: ‘3c3e041f-dd85-4602-9b03-ae3da6db254f’, ‘neutron.net.shared’: ‘False’, ‘neutron.subnet.uuid’: ‘d399795d-8969-4913-a4ad-1638737b1a8c’ _create_network_attempt /usr/local/lib/python3.6/site-packages/zun/network/kuryr_network.py:168
2021-04-21 23:38:17.212 308243 DEBUG zun.network.kuryr_network [req-9d7cd349-c488-4d60-a2b5-d70d9577cf62 89805c2a82ea4780a6335bb42fef17e5 74b67e24d3bf403d895025c63e0a31dc default - -] Attempt (1) to create network: Network(created_at=<?>,id=<?>,name=‘0ba5db0f-2040-4979-ad74-8d187f1442c6’,network_id=<?>,neutron_net_id=0ba5db0f-2040-4979-ad74-8d187f1442c6,project_id=74b67e24d3bf403d895025c63e0a31dc,updated_at=<?>,user_id=‘89805c2a82ea4780a6335bb42fef17e5’,uuid=<?>) create_network /usr/local/lib/python3.6/site-packages/zun/network/kuryr_network.py:120
2021-04-21 23:38:17.217 308243 DEBUG zun.network.kuryr_network [req-9d7cd349-c488-4d60-a2b5-d70d9577cf62 89805c2a82ea4780a6335bb42fef17e5 74b67e24d3bf403d895025c63e0a31dc default - -] Calling docker.create_network to create network 0ba5db0f-2040-4979-ad74-8d187f1442c6, ipam_options ‘Driver’: ‘kuryr’, ‘Options’: ‘neutron.net.shared’: ‘False’, ‘neutron.subnet.uuid’: ‘6a89c673-5fb6-4b44-8b18-a2180b128bfc’, ‘Config’: [‘Subnet’: ‘172.21.0.0/16’, ‘Gateway’: None], options ‘neutron.net.uuid’: ‘0ba5db0f-2040-4979-ad74-8d187f1442c6’, ‘neutron.net.shared’: ‘False’, ‘neutron.subnet.uuid’: ‘6a89c673-5fb6-4b44-8b18-a2180b128bfc’ _create_network_attempt /usr/local/lib/python3.6/site-packages/zun/network/kuryr_network.py:168
2021-04-21 23:38:17.787 308243 ERROR zun.compute.manager [req-9d7cd349-c488-4d60-a2b5-d70d9577cf62 89805c2a82ea4780a6335bb42fef17e5 74b67e24d3bf403d895025c63e0a31dc default - -] Error occurred while calling Docker create API: Docker internal error: 500 Server Error for http+docker://localhost/v1.26/networks/create: Internal Server Error (“failed to allocate gateway (): No address returned”).: zun.common.exception.DockerError: Docker internal error: 500 Server Error for http+docker://localhost/v1.26/networks/create: Internal Server Error (“failed to allocate gateway (): No address returned”).
解决办法:
方法一、在neutron创建子网的时候,启用网关,给出网关ip地址;之后第一次创建容器后可以禁用网关,后续不会有影响。
方法二、修改组件源码后重新编译安装一次
解决办法:
cd /var/lib/zun/zun/
vim zun/network/kuryr_network.py
# 对98行修改
# 将:"Gateway": v4_subnet[gateway_ip]
# 修改为:"Gateway": v4_subnet[gateway_ip] or "10.0.0.1"
python3 setup.py install
systemctl restart zun-compute.service
cd /var/lib/kuryr/kuryr-libnetwork/
vim kuryr_libnetwork/controllers.py
# 在819行添加以下内容:
# if not v4_gateway_ip:
# v4_gateway_ip = "10.0.0.1"
python3 setup.py install
systemctl restart kuryr-libnetwork.service
docker网络相关使用方法:
docker网桥删除了,进行恢复:
systemctl daemon-reload
systemctl restart docker
ifconfig
docker 网络创建:
docker network create --driver bridge --subnet 10.0.77.1/24 --gateway 10.0.77.1 docker0
docker网络删除:
ifconfig docker0 down &>/dev/null
brctl delbr docker0 &>/dev/null
网卡启动停止:
ifdown ifcfg-enp7s0 关闭网卡
ifup
以上是关于docker 创建网络 failed to allocate gateway (): No address returned 解决办法的主要内容,如果未能解决你的问题,请参考以下文章
ERROR: [Common 17-356] Failed to install all user apps.
java.io.IOException: All specified directories have failed to load.
Altium输出Gerber提示Gerber failed to match all shapes解决办法
service docker start 报错 :Failed to start docker.se
Docker启动不了,提示 Docker failed to initialize,怎么办
triton-inference-server启动报Internal - failed to load all models