Docker Community Forums

Share and learn in the Docker community.

Docker Networking across a swarm

Hello Guys,

Before I go into this yes I have searched this and I do not understand unfortunately. I am not a real networking guy per se.

I was wondering how I would go about sharing a network segment across all 5 nodes of my swarm I am creating it this way right now:
docker network create -d macvlan -o parent=eth0 --subnet --gateway --ip-range CFSNET but I am having to do that on every node. Then I got to thinking that the range would allow IPs to be duplicated because they would be independent of each node there for on host1 you could have a .32 and on host3 you could have a .32. I hope this is clear. I just need to understand which driver I use to spread the ip range across all 5 nodes collectively and not get duplicate ips on my containers?

I see this when I type docker network ls

I am suspecting I will have to do something similar

Thanks for your help,

If you create an overlay network on any mater, the network will be created for you on each node that has a container/task connected to it.

Never tried it with macvlan though, not sure if it behaves the same like overlay networks.
Though, I actualy never needed macvlan… not even in the more complex setups I did so far…

I am pretty sure it doesn’t and won’t let you do that, after reading some more I believe I would have to create a bridge and do my ip range in that fashion. I am just not a network guy so this is going to be a challenge for me.

Thanks for your response,

I think I just found my own answer and since I had to search for this for a couple of hours, I figured I would share it here with everyone. Apparently overlays don’t allow more than 256 IP addresses there for you have to split them into subnets with /25 or what ever it is you want to use. So, the way I am planning it, is to use one /25 and 2 - /26s This should get me where I need to be of course this is the format it has to be in:

docker network create -d overlay \
  --subnet= \
  --subnet= \
  --gateway= \
  --gateway= \
  --aux-address="my-router=" --aux-address="my-switch=" \
  --aux-address="my-printer=" --aux-address="my-nas=" \

source: Docker Documentation

Like I said I am not a network guy, I will have to experiment to get this right. I am thinking this would have to be the way it needs to be defined, something of this sort anyway. I hope this helps someone else as well.