Docker Community Forums

Share and learn in the Docker community.

Bind a specific network interface for a particular overlay network?

Hi, is there a way to bind a specific network interface for a particular overlay network? The reason for this is that DigitalOcean (as well as other cloud providers) offer private networking which allows you to communicate to other VMs within the same data center (region) without going over the public internet and being charged.

If I’m correct, the network interface that each overlay network created on a node goes over is specified when you join the swarm with --advertise-addr. Is it possible to somehow use this as a default, but in addition, when we create a new overlay network we can explicitly specify the network interface we want to use?

ie. docker network create -d overlay --iface eth1 myoverlaynetwork or docker network create -d overlay --internal-ip PRIVATE_IP myoverlaynetwork

In my opinion, this is not even an ideal approach to the problem because not every distribution names their network interfaces with ethX.

Ultimately, I want to define these overlay networks in a service stack config so I can docker stack deploy my services so that they go over the private network instead of the public internet.

Also, I have several services running in different regions/data centers, which communicate with each other through a global overlay network. The services that are running in the same region, however, should communicate through the private network interface which I am trying to do via another overlay network.

I was also looking into macvlan to do the networking, but I’m not entirely sure how to set it up. DigitalOcean gives a public ip address, gateway and netmask, but for its private network, I only see the private ip address and netmask, no gateway.

1 Like

Use bridge networks when you need a relatively small network on a single host. Containers you create on your custom bridge network must exist on the same host. Docker does not support linking on bridge networks you define. To know more join networking training course to enhance your knowledge.