{"action":"created","issue":{"url":"https://api.github.com/repos/docker/libnetwork/issues/915","labels_url":"https://api.github.com/repos/docker/libnetwork/issues/915/labels{/name}","comments_url":"https://api.github.com/repos/docker/libnetwork/issues/915/comments","events_url":"https://api.github.com/repos/docker/libnetwork/issues/915/events","html_url":"https://github.com/docker/libnetwork/issues/915","id":129887229,"number":915,"title":"creating multiple bridge networks concurrently fails","user":{"login":"campbellr","id":205752,"avatar_url":"https://avatars.githubusercontent.com/u/205752?v=3","gravatar_id":"","url":"https://api.github.com/users/campbellr","html_url":"https://github.com/campbellr","followers_url":"https://api.github.com/users/campbellr/followers","following_url":"https://api.github.com/users/campbellr/following{/other_user}","gists_url":"https://api.github.com/users/campbellr/gists{/gist_id}","starred_url":"https://api.github.com/users/campbellr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/campbellr/subscriptions","organizations_url":"https://api.github.com/users/campbellr/orgs","repos_url":"https://api.github.com/users/campbellr/repos","events_url":"https://api.github.com/users/campbellr/events{/privacy}","received_events_url":"https://api.github.com/users/campbellr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-29T21:28:42Z","updated_at":"2016-01-29T22:13:12Z","closed_at":null,"body":"I have some tests that spins up containers in a bridged network, but when i run tests in parallel i end up getting failures like this:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.4/threading.py\", line 920, in _bootstrap_inner\r\n    self.run()\r\n  File \"/usr/lib/python3.4/threading.py\", line 868, in run\r\n    self._target(*self._args, **self._kwargs)\r\n  File \"docker_test.py\", line 11, in create_network\r\n    n = c.create_network(name)\r\n  File \"/localhome/campbr9/.local/lib/python3.4/site-packages/docker/utils/decorators.py\", line 35, in wrapper\r\n    return f(self, *args, **kwargs)\r\n  File \"/localhome/campbr9/.local/lib/python3.4/site-packages/docker/api/network.py\", line 29, in create_network\r\n    return self._result(res, json=True)\r\n  File \"/localhome/campbr9/.local/lib/python3.4/site-packages/docker/client.py\", line 146, in _result\r\n    self._raise_for_status(response)\r\n  File \"/localhome/campbr9/.local/lib/python3.4/site-packages/docker/client.py\", line 142, in _raise_for_status\r\n    raise errors.APIError(e, response, explanation=explanation)\r\ndocker.errors.APIError: 409 Client Error: Conflict (\"b'cannot create network br-2912151829a5 (0548ba54b35ce9b10e4fedeab3b081bb845d019372533c9f16b88377bf2e713c): conflicts with network 2912151829a51ab8b4c68a13474f427ae28d1983b36a1a0d18c2acbf60221334 (br-2912151829a5): networks have overlapping IPv4'\")\r\n```\r\n\r\n(I've filed #914 to cover the fact that the error message implies that both networks have the same bridge name, which isn't really the case)\r\n\r\nIt seems like something in the network creation isn't properly serialized, although I'm not familiar enough with the code to tell where the problem is.\r\n\r\nThis is my docker version:\r\n\r\n```\r\n$ docker --version\r\nDocker version 1.9.1, build a34a1d5\r\n```\r\n\r\n\r\nAnd the trivial test I wrote to reproduce:\r\n\r\n```python\r\nfrom uuid import uuid4\r\nfrom threading import Thread\r\nfrom docker import Client\r\n\r\nc = Client()\r\n\r\n\r\ndef create_network():\r\n    name = uuid4().hex  # just making sure the name is unique\r\n    n = c.create_network(name)\r\n    c.remove_network(n['Id'])\r\n\r\n\r\nif __name__ == '__main__':\r\n    threads = []\r\n\r\n    for i in range(10):\r\n        t = Thread(target=create_network)\r\n        t.start()\r\n        threads.append(t)\r\n\r\n    for t in threads:\r\n        t.join()\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/docker/libnetwork/issues/comments/176992839","html_url":"https://github.com/docker/libnetwork/issues/915#issuecomment-176992839","issue_url":"https://api.github.com/repos/docker/libnetwork/issues/915","id":176992839,"user":{"login":"aboch","id":10080882,"avatar_url":"https://avatars.githubusercontent.com/u/10080882?v=3","gravatar_id":"","url":"https://api.github.com/users/aboch","html_url":"https://github.com/aboch","followers_url":"https://api.github.com/users/aboch/followers","following_url":"https://api.github.com/users/aboch/following{/other_user}","gists_url":"https://api.github.com/users/aboch/gists{/gist_id}","starred_url":"https://api.github.com/users/aboch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aboch/subscriptions","organizations_url":"https://api.github.com/users/aboch/orgs","repos_url":"https://api.github.com/users/aboch/repos","events_url":"https://api.github.com/users/aboch/events{/privacy}","received_events_url":"https://api.github.com/users/aboch/received_events","type":"User","site_admin":false},"created_at":"2016-01-29T22:13:11Z","updated_at":"2016-01-29T22:13:11Z","body":"@campbellr \r\nThis seems to be the cause: `[...]  networks have overlapping IPv4`\r\n\r\nThere was a race in the code which selects the subnet to assign to the network being created. Fixed it with #890. Docker 1.10 will have the fix.\r\n"}}