I want to practise in creation of high-available web-application using multiple Docker containers on one machine.
I launch several web-servers within Docker containers. Say, three servers
I use Docker with HAProxy balancer, which is binded to
127.0.0.1:80 and routes queries to
rest servers. This allows me to be sure, that when one or two
rest servers failed, I will be able to make queries to
127.0.0.1:80 and receive correct results.
The bad thing is: when HAProxy is down, web-application is down.
I want to use several HAProxy Docker containers with Keepalived service in each container.
The problem is: I need several Docker containers to listen to one IP and one PORT. E.g., I will have
haproxy2, which will be binded to
localhost via Keepalived.
When I set IP in HAProxy configuration file, which is not an IP of current Docker container, it shows me an error, that HAProxy cannot listen this IP and PORT.
Is it possible to configure multiple Docker containers with HAProxy and Keepalived to listen to one IP and PORT?
Configuration of HAProxy:
defaults timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend http-in mode http bind 172.17.0.10:80 default_backend BACKEND backend BACKEND option httpchk server rest1 rest1:8080 maxconn 32 check server rest2 rest2:8080 maxconn 32 check server rest3 rest3:8080 maxconn 32 check
fails with error
Starting frontend http-in: cannot bind socket [172.17.0.10:80]
172.17.0.10 is a member of Docker subnetwork and not reserved on my machine.