Answers: <p>You might be interested in this more flexible Docker Swarm alternative: <a href="https://overnode.org/" rel="nofollow noreferrer">https://overnode.org/</a> . You can see it as multi-host docker compose without Swarm, but it is a bit more than this. It has got a great set of features. It also supports static IP addresses. (Disclaimer: I am an author of the project)</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-08-04T12:14:19.367Z
Answers: 2020-08-04T12:14:19.367Z
Answers: Andrew
Answers: <p>On June 30, 2016 <a href="https://github.com/moby/moby/issues/24170" rel="nofollow noreferrer">this issue</a> was created on GitHub to request the implementation of static IP on docker-swarm services.</p>
  
  <p>Since then multiple replies with thumbs up and down were added.</p>
  
  <p>At the time of writing on December 20, 2019 this issue is open and the feature has not been implemented.</p>
  
  <p><strong>Discussion</strong></p>
  
  <p>After reading all comments I strongly doubt whether static IPs will ever be implemented in docker-swarm. On the other hand it is unclear why this issue has not been closed. If people would like to see that this feature gets implemented, one could create a Pull request or add a thumbs up to create more awareness.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-12-20T10:35:13.467Z
Answers: 2019-12-20T13:25:44.613Z
Answers: 2019-12-20T13:25:44.613Z
Answers: 030
Body: <p>Situation:</p>
  
  <ol>
  <li>docker swarm with 3+ nodes</li>
  <li>service running in the swarm with replicas=1 and restart=always</li>
  <li>swarm hosts have multiple interfaces - one for each vlan, with the same name</li>
  <li>service is deployed as a stack </li>
  </ol>
  
  <p>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.</p>
  
  <p>What options do I have for one or more services to have static ips ?</p>
  
  <p>A. added ipv4_address in docker stack yml - does not seem to be implemented in docker (at least not yet)</p>
  
  <p>B. add a new host with reverse proxies to the docker stack services</p>
  
  <p>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:: ...</p>
  
  <p>D. ... ?</p>
  
  <p>Are there any "better" ways of doing this?</p>
  
  <hr>
  
  <p>I tried doing this:</p>
  
  <p>on each docker host:</p>
  
  <pre><code>docker network create --config-only --subnet="&lt;CIDR&gt;" --ip-range="&lt;CIDR&gt;" -o parent="INTERFACE" "vlan_name_intermediate"
  </code></pre>
  
  <p>and then a global network for the whole swarm</p>
  
  <pre><code>docker network create -d macvlan --scope swarm --config-from "vlan_name_intermediate" "vlan_name"
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>ipv4_address: "192.168.45.56"
  </code></pre>
  
  <p>where the ip is inside the CIDR ip-range, but the setting is ignored</p>
  
Comments: CC BY-SA 4.0
Comments: 2018-06-04T08:46:49.393Z
Comments: Why do you need a static ip ? That's the first point to address, addressing the rest if there's no imperious need for a static ip is a XY problem.
Comments: Tensibai
Comments: CC BY-SA 4.0
Comments: 2018-06-04T11:39:47.337Z
Comments: Multiple reasons: (1) legacy software that needs to talk to other legacy software set to specific ip+port via the licence file (and i need to move on service at a time and (2) network-wide services like dhcp / dns which are used via apis by other services in the network that connect via ip+port (no hostname option).
Comments: vlad b.
Comments: CC BY-SA 4.0
Comments: 2018-06-04T12:08:07.210Z
Comments: Then C is your only option (B is just adding another machine in place of the actual), but surely you shouldn't try to convert those services to containers in first place, you're heading toward a path full of pain twisting technologies for something they've not been built for and just adding a layer between your host and your app for not benefit at all.
Comments: Tensibai
Comments: CC BY-SA 4.0
Comments: 2019-06-27T04:46:26.977Z
Comments: I have the same situation, did you find a good solution?
Comments: eval
Comments: CC BY-SA 4.0
Comments: 2019-08-07T09:34:20.197Z
Comments: @eval no, i moved some services to a proxmox host
Comments: vlad b.
Tags: <docker-swarm>
Title: Options to assign a static ip to a service running in docker swarm
UserDisplayName: vlad b.
ThreadText: # Options to assign a static ip to a service running in docker swarm
  
  (Asked by: username_0 on 2018-06-04)
  
  Situation:
  
  1. docker swarm with 3+ nodes
  2. service running in the swarm with replicas=1 and restart=always
  3. swarm hosts have multiple interfaces - one for each vlan, with the same name
  4. 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:
  
  ```
  ipv4_address: "192.168.45.56"
  
  ```
  
  where the ip is inside the CIDR ip-range, but the setting is ignored
  
  **Tags:** docker-swarm
  
  > **Comments:**
  > **username_1**: Why do you need a static ip ? That's the first point to address, addressing the rest if there's no imperious need for a static ip is a XY problem.  
  > **username_0**: Multiple reasons: (1) legacy software that needs to talk to other legacy software set to specific ip+port via the licence file (and i need to move on service at a time and (2) network-wide services like dhcp / dns which are used via apis by other services in the network that connect via ip+port (no hostname option).  
  > **username_1**: Then C is your only option (B is just adding another machine in place of the actual), but surely you shouldn't try to convert those services to containers in first place, you're heading toward a path full of pain twisting technologies for something they've not been built for and just adding a layer between your host and your app for not benefit at all.  
  > **username_2**: I have the same situation, did you find a good solution?  
  > **username_0**: @username_2 no, i moved some services to a proxmox host  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2019-12-20. Score: 4 | Accepted answer
  
  On June 30, 2016 [this issue](https://github.com/moby/moby/issues/24170) was created on GitHub to request the implementation of static IP on docker-swarm services.
  
  Since then multiple replies with thumbs up and down were added.
  
  At the time of writing on December 20, 2019 this issue is open and the feature has not been implemented.
  
  **Discussion**
  
  After reading all comments I strongly doubt whether static IPs will ever be implemented in docker-swarm. On the other hand it is unclear why this issue has not been closed. If people would like to see that this feature gets implemented, one could create a Pull request or add a thumbs up to create more awareness.
  
  
  ---
  
  ### Answer by username_3 on 2020-08-04. Score: 0
  
  You might be interested in this more flexible Docker Swarm alternative: <https://overnode.org/> . You can see it as multi-host docker compose without Swarm, but it is a bit more than this. It has got a great set of features. It also supports static IP addresses. (Disclaimer: I am an author of the project)
  
  
  ---
  
  