配合hub.docker.com
的dablyo/haproxy-keepalived-nodejsv9:190407 使用的
[root@haproxy ~]# cat haproxy.cfg
global
daemon
maxconn 256
pidfile /root/haproxy.pid
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:3000
default_backend servers
backend servers
balance roundrobin
server s0 172.18.0.2:3000 maxconn 32
server s1 172.18.0.3:3000 maxconn 32
和
[root@haproxy ~]# cat sources.list.jessie
deb http://mirrors.163.com/debian/ jessie main non-free contrib
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
以及
[root@haproxy ~]# cat create-cotainer.sh
docker network rm ha-net
sleep 1
echo "docker network ha-net has been removed..."
docker stop hanode0
docker stop hanode1
docker rm hanode0
docker rm hanode1
echo "docker container hanode0 and hanode1 have been removed..."
docker network create --subnet 172.18.0.0/16 ha-net
echo "docker network create --subnet 172.18.0.0/16 ha-net..."
sleep 3
docker create -it --ip 172.18.0.2 --name hanode0 --network ha-net \
--restart="always" --privileged="true" \
-e INTERFACE="eth0" \
-e STATE="MASTER" \
-e VIRTUAL_ROUTER_ID="51" \
-e PRIORITY="101" \
-e VIRTUAL_IP="172.18.0.254" \
-e VIRTUAL_MASK="24" \
-v haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /root/.docker:/root/.docker \
-v /root/sources.list.jessie:/etc/apt/sources.list dablyo/haproxy-keepalived-nodejsv9:190407 \
[/usr/local/sbin/haproxy] [-f, /usr/local/etc/haproxy/haproxy.cfg]
sleep 3
docker create -it --ip 172.18.0.3 --name hanode1 --network ha-net \
--restart="always" --privileged="true" \
-e INTERFACE="eth0" \
-e STATE="SLAVE" \
-e VIRTUAL_ROUTER_ID="51" \
-e PRIORITY="101" \
-e VIRTUAL_IP="172.18.0.254" \
-e VIRTUAL_MASK="24" \
-v haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /root/.docker:/root/.docker \
-v /root/sources.list.jessie:/etc/apt/sources.list dablyo/haproxy-keepalived-nodejsv9:190407 \
[/usr/local/sbin/haproxy] [-f, /usr/local/etc/haproxy/haproxy.cfg]