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 192.168.10.0/24 --gateway 192.168.10.1 --ip-range 192.168.10.192/27 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
network-overlay-ingress

I am suspecting I will have to do something similar

Thanks for your help,
Michael

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,
Michael

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=192.168.1.0/25 \
  --subnet=192.170.2.0/25 \
  --gateway=192.168.1.100 \
  --gateway=192.170.2.100 \
  --aux-address="my-router=192.168.1.5" --aux-address="my-switch=192.168.1.6" \
  --aux-address="my-printer=192.170.1.5" --aux-address="my-nas=192.170.1.6" \
  my-multihost-network

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.

Thanks,
Michael