Hi everyone,
We’re working on a setup where specific containers in Docker Swarm need to have static IP addresses. To achieve this, we’re using macvlan
networks, alongside HAProxy for load balancing across these services.
Our approach involves creating a unique macvlan
network for each service as follows:
- Config-Only Network Creation (on all Swarm servers):
bash
Copy code
docker network create -d macvlan --config-only --subnet=192.168.110.0/24 --gateway=192.168.110.1 --ip-range=192.168.110.12/32 parent=ens193 app01
- Swarm Network Creation (on manager):
bash
Copy code
docker network create -d macvlan --scope swarm --config-from app01 swarm_app01
For new applications, we add additional virtual network adapters (e.g., ens224
) and assign new networks with static IPs.
The issue is that, after successfully setting up and running four IPs and networks, any attempt to create a fifth network now results in the following error:
css
Copy code
failed to allocate gateway (192.168.110.1): address already in use
We’re running Docker version 27.1.2 (build d01f265).
Is anyone familiar with this error, or does anyone have alternative suggestions for assigning static IPs to services within a Docker Swarm? Any help or insight would be appreciated!