Hi, I have 3 node docker swarm. I’m trying to run a number of applications that use multicast for discovery and decided to use MACVLAN so that they’d have an IP address on the existing subnet.
Using portainer, I configured a MACVLAN config for each node of
Subnet - 192.168.1.0/24
Gateway - 192.268.1.254
IP Range - 192.168.1.192/28
The resulting config is:
[
{
"Name": "mfo-network",
"Id": "f3a841c058980cc47ce67c56184e1c6a246f84638af4636bc93b567237e31050",
"Created": "2025-05-03T13:48:57.451545374-04:00",
"Scope": "local",
"Driver": "null",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.1.0/24",
"IPRange": "192.168.1.192/28",
"Gateway": "192.168.1.254"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": true,
"Containers": {},
"Options": {
"parent": "eno1"
},
"Labels": {}
}
]
I then created a network for the containers to attach to:
[
{
"Name": "mfonet",
"Id": "lgowmxtub0zsgbw0t3wo9y2xj",
"Created": "2025-05-03T17:50:14.585793545Z",
"Scope": "swarm",
"Driver": "macvlan",
"EnableIPv6": false,
"IPAM": {
"Driver": "",
"Options": null,
"Config": []
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": "mfo-network"
},
"ConfigOnly": false,
"Containers": null,
"Options": null,
"Labels": null
}
]
When I start the stacks, each container is assigned an IP address and MAC address as expected, but each node seems to work independently, so the first application on each node is always assigned
IP address: 192.168.1.192
MAC: 02:42:c0:a8:01:c0
Which is obviously not useful.
How should MACVLAN be configured so that each container always gets a unique IP address? Do I have to create different subnet range for each node, and then connect them with the same network definition?
Thanks
Alan