我尝试运行我的Screen-shot of the error套件,但遇到了这个问题:
docker.errors.APIError:500服务器错误:内部服务器错误(" b' {"消息":"无法分配网关(10.49.0.201):地址已经在使用"}'")
我尝试删除所有正在运行的容器和相关网络,但仍然遇到了问题。
内核
$ uname
Linux x1 4.8.0-36-generic #36~16.04.1-Ubuntu SMP Sun Feb 5 09:39:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
泊坞
$ docker --version
Docker version 1.13.1, build 092cba3
SDK
docker-py==1.10.6
在进行测试之前,我处于这种状态:
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
a4beb5d4de56 bridge bridge local
8a1012b67f1a host host local
ed2452ee5e44 none null local
没有容器在运行 $ docker ps -a 集装箱ID图像命令创建状态端口名称
def test_get_network_config(self):
number_networks = len(self.docker_api.networks())
network_config = container_services.get_network_config(
data={
'ip': '10.49.0.1',
'subnet': '10.49.0.0/16',
'gateway': '10.49.0.201',
'vlan': 101
},
docker_client=self.docker_api
)
network_id = list(network_config.get('EndpointsConfig').keys())[0]
self.assertEqual(number_networks + 1, len(self.docker_api.networks()))
self.docker_api.remove_network(network_id)
def get_network_config(data, docker_client):
network = create_network(data, docker_client)
network_name = docker_client.inspect_network(network.get('Id')).get('Name')
network_info = dict()
network_info[network_name] = docker_client.create_endpoint_config(ipv4_address=data.get('ip'))
networking_config = docker_client.create_networking_config(network_info)
return networking_config
ERROR: test_get_network_config (backend.api.tests.test_container_services.ContainersTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/data/projects/coaxis-opt/env/lib/python3.5/site-packages/docker/client.py", line 170, in _raise_for_status
response.raise_for_status()
File "/data/projects/coaxis-opt/env/lib/python3.5/site-packages/requests/models.py", line 909, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localunixsocket/v1.24/networks/create
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/projects/coaxis-opt/backend/api/tests/test_container_services.py", line 93, in test_get_network_config
docker_client=self.docker_api
File "/data/projects/coaxis-opt/backend/api/container_services.py", line 31, in get_network_config
network = create_network(data, docker_client)
File "/data/projects/coaxis-opt/backend/api/container_services.py", line 65, in create_network
options={"parent": get_default_interface(data)})
File "/data/projects/coaxis-opt/env/lib/python3.5/site-packages/docker/utils/decorators.py", line 35, in wrapper
return f(self, *args, **kwargs)
File "/data/projects/coaxis-opt/env/lib/python3.5/site-packages/docker/api/network.py", line 62, in create_network
return self._result(res, json=True)
File "/data/projects/coaxis-opt/env/lib/python3.5/site-packages/docker/client.py", line 178, in _result
self._raise_for_status(response)
File "/data/projects/coaxis-opt/env/lib/python3.5/site-packages/docker/client.py", line 174, in _raise_for_status
raise errors.APIError(e, response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("b'{"message":"failed to allocate gateway (10.49.0.201): Address already in use"}'")
答案 0 :(得分:2)
我正在使用相同的配置编写一个新的测试但忘记在完成时销毁容器因此错误...
答案 1 :(得分:0)
我发生了同样的错误。问题是不同服务器的docker版本。举个例子 例如:
server_1:docker version 1.13.11
server_2:docker version 18.03.1-ce
所以我将所有服务器更新到18.03.1-ce的相同版本,现在它工作正常。
答案 2 :(得分:0)
答案 3 :(得分:0)
在尝试通过将bip
选项添加到daemon.json
来更改Docker工作的IP范围之后,出现了此错误。问题是我误读了文档,bip
不是子网,而是网桥IP和子网。
我已将bip
指定为x.x.x.0/24
,因此它试图将x.x.x.0
分配为失败的IP地址。将bip
设置为x.x.x.1/24
可以解决此问题。