Docker Ip Failover Docker Ip Failover docker docker

Docker Ip Failover


Here's your network:

network diagram

You may have only one Docker host for now, but the point of having a IP failover is to be able to switch the traffic to a different host without making users change the destination IP address.

Let's assume you have 2 docker hosts which are identical, except for the IP address of their main network interface (eth0).

You want to run your docker container on both hosts and you want the apache web server running inside your containers to answer for the 2 IP addresses of each host.

On docker host A, start your docker container with docker run -p 9000:80 ....

On docker host B, also start your docker container with docker run -p 9000:80 ....


Now, when on your hosting provider admin panel, you assign the IP failover 62.1.2.3 to host A, you will be able to:

  • query host A web server with http://62.1.2.3:9000/
  • query host A web server with http://192.0.0.17:9000/
  • query host B web server with http://192.0.0.47:9000/

Later on, when on your hosting provider admin panel, you assign the IP failover 62.1.2.3 to host B, you will be able to:

  • query host B web server with http://62.1.2.3:9000/
  • query host A web server with http://192.0.0.17:9000/
  • query host B web server with http://192.0.0.47:9000/

It is important that you can also query your web servers with 192.0.0.17 and 192.0.0.47 IP addresses, at least, to test web servers are up and running on both hosts, whatever the IP failover setting.


Thank you very much @thomasleveil that answer actualy respond to my question.

I would have thought it would have been more complicated but finaly i did this.

For resume, i had setup my IPFO something like this :

source /etc/network/interfaces.d/*# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet static    address 195.x.x.x    netmask 255.255.255.0    gateway 195.x.x.xauto eth0:0    iface eth0:0 inet static    address 62.x.x.x    netmask 255.255.255.255

Run my container with :

$ docker run -it --name ubuntu_01 -p 9000:80 docker/box tail -f /dev/null

I can access to my container from the web from main server IP and IPFO.

I think this is a basic configuration but it's work !

I would like up vote your answer but stackoverflow forbidden the up vote from new member.

Thank you again for your time :)