- docker swarm with 3+ nodes
- service running in the swarm with replicas=1 and restart=always
- swarm hosts have multiple interfaces - one for each vlan, with the same name
- service is deployed as a stack
I want to replace a service running in a VM on a static IP with the same one running docker, but I need to have the same SERVICE_IP on the ETH_SERVER interface.
What options do I have for one or more services to have static ips ?
A. added ipv4_address in docker stack yml - does not seem to be implemented in docker (at least not yet)
B. add a new host with reverse proxies to the docker stack services
C. use keepalived on the docker hosts and map SERVICE_IP - in this way if a host goes down the floating ip gets reassigned - but not sure if I could expose ports with FLOATING_SERVICE_IP:: ...
D. ... ?
Are there any "better" ways of doing this?
I tried doing this:
on each docker host:
docker network create --config-only --subnet="<CIDR>" --ip-range="<CIDR>" -o parent="INTERFACE" "vlan_name_intermediate"
and then a global network for the whole swarm
docker network create -d macvlan --scope swarm --config-from "vlan_name_intermediate" "vlan_name"
Now if I attach a service to network "vlan_name" i can ping it from inside that vlan, but the IP is randomly assigned, not static. I tried adding this to the compose yaml file:
where the ip is inside the CIDR ip-range, but the setting is ignored