devplayer0 / docker-net-dhcp

Docker network driver for networking on a host bridge with DHCP-allocated IP addresses
GNU General Public License v3.0
193 stars 55 forks source link

Can't connect multiple networks to a single container #21

Closed zackzane closed 3 years ago

zackzane commented 3 years ago

I have created two different networks attached to two different bridges. When i connect the first network to the container, it has no problems. When i connect the 2nd one, i get this error:

Error response from daemon: failed to add interface 55c1b19cd7cc-dh to sandbox: error setting interface "55c1b19cd7cc-dh" routes to ["169.254.0.0/16"]: file exists

It doesn't matter which network goes first, the first will always succeed, and the second will fail with roughly that error. I have needs for providing upwards of 5 or 6 networks from this plugin, all with different bridges, so I'm hoping there is a solution here. Let me know if you need anything else from me to help sort this out. Thanks.

zackzane commented 3 years ago

I thought I'd add to this.. This morning I came back to it and looked further into it, and it actually looks like it sort of works. If I have a container running, and then i run 'docker network connect ' .. it works for the first network. Running it for the second network gives the error above. However running 'docker inspect ' does actually show both interfaces with IP addresses issued via DHCP. In addition to that, if I have the container created but not started, I can connect both networks just fine without errors, but as soon as I try to start the container up, I get the following error:

_Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: processlinux.go:545: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , stderr: time="2021-07-14T14:13:40Z" level=fatal msg="failed to add interface 6cc5ac2b99ed-dh to sandbox: error setting interface \"6cc5ac2b99ed-dh\" routes to [\"169.254.0.0/16\"]: file exists": unknown

After this error, the container has not started. If i either one of the networks from the container, it will then start right up.

Pulling up the logs after attempting to add the second network to a running container: time="2021-07-14T14:27:34Z" level=info msg="Endpoint created" endpoint=15faa4a8d46b gateway="\"10.1.0.254\"" ip=10.1.0.88/24 ipv6= mac_address="0a:ac:e9:db:87:aa" network=b5f464fb91c4 time="2021-07-14T14:27:34Z" level=info msg="[Join] Setting IPv4 gateway retrieved from initial DHCP in CreateEndpoint" endpoint=15faa4a8d46b gateway=10.1.0.254 network=b5f464fb91c4 sandbox=/var/run/docker/netns/ad8ed341024a time="2021-07-14T14:27:34Z" level=info msg="[Join] Adding on-link route retrieved from bridge interface on host routing table" endpoint=15faa4a8d46b network=b5f464fb91c4 route=169.254.0.0/16 sandbox=/var/run/docker/netns/ad8ed341024a time="2021-07-14T14:27:34Z" level=info msg="Joined sandbox to endpoint" endpoint=15faa4a8d46b network=b5f464fb91c4 sandbox=/var/run/docker/netns/ad8ed341024a time="2021-07-14T14:27:34Z" level=error msg="Error while processing request" error="missing joined endpoint state" time="2021-07-14T14:27:34Z" level=info msg="Endpoint deleted" endpoint=15faa4a8d46b network=b5f464fb91c4

devplayer0 commented 3 years ago

Looks like there's an issue where the plugin is trying to add a link-local route to the container that already exists. Can you try using the skip_routes option I just added in v0.1.4?

zackzane commented 3 years ago

That's looks like it solved it. Thanks!.