2

I'm trying to create a Docker network which would use an existing bridge on the host but without configuring any IP on this bridge. When I run:

docker network create -o "com.docker.network.bridge.name=br0" testnet

Docker automatically assign an IP address on the host and always use this IP as the gateway for other containers.

What I want is a network without an IP on the host and to use another container as the gateway (this container is connected to multiple networks). I have very good reasons for this setup and not letting the host directly route between these networks. Is it possible and how can I achieve that?

Thank you in advance for your help,

spongebob

2
  • Did you try docker network create --internal ...
    – BMitch
    Aug 11, 2017 at 21:42
  • Yes, the only difference --internal makes is that it adds some iptables rules so containers cannot communicate with other networks. But it still adds an IP address on the host.
    – spongebob
    Aug 11, 2017 at 23:38

1 Answer 1

2

After looking at the source code it does not seem possible to do that with the bridge network driver. The createNetwork function always tries to setup an IPv4 even if the bridge already exists. The setupBridgeIPv4 function sets up an IPv4 on the bridge and defines this IP as the gateway for the network.

I solved my problem by using the none network driver and using pipework to manually attach the containers to my host bridge. The disadvantage of this solution is that containers must be re-attached to the bridges each time they are restarted but that can be automated with a systemd service starting after the docker one.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .