Start Docker
# build dockerfile
sudo docker build -t keepalived .
# docker run
sudo docker run -d --rm \
--cap-add=NET_ADMIN \
--net=host \
-e KEEPALIVED_ROUTER_ID=1 \
-e KEEPALIVED_STATE=MASTER \
-e KEEPALIVED_PRIORITY=100 \
-e KEEPALIVED_PASSWORD=1111 \
-e KEEPALIVED_INTERFACE=ovs_eth0 \
-e KEEPALIVED_UNICAST_PEERS=192.168.0.100,192.168.0.246 \
-e KEEPALIVED_VIRTUAL_IPS=192.168.0.180 \
keepalived
Start docker compose
version: '3.5'
services:
keepalived:
build: .
environment:
KEEPALIVED_ROUTER_ID: 1 # [require] RouterID
KEEPALIVED_STATE: MASTER # Defualt State MASTER, BACKUP, default : BACKUP
KEEPALIVED_PRIORITY: 100 # priority, defualt : 1~199 random
KEEPALIVED_PASSWORD: 1111 # auth password
KEEPALIVED_INTERFACE: ovs_eth0 # [require] network interface in host
KEEPALIVED_UNICAST_PEERS: 192.168.0.100,192.168.0.246 # [require] peer clients, split comma
KEEPALIVED_VIRTUAL_IPS: 192.168.0.180 # [require] virtual ip, split comma
network_mode: host
cap_add:
- NET_ADMIN