haproxy-keepalived
Load balancing, VRRP with failover for high availability.
2.9K
A robust, selfhost-ready Docker container combining HAProxy load balancing with Keepalived for high availability. This solution provides automatic failover capabilities and efficient load distribution for your services.
# Pull the image
docker pull peterweissdk/haproxy-keepalived
# Run with custom configuration
docker run -d \
--name haproxy-keepalived \
--cap-add=NET_ADMIN \
--cap-add=NET_BROADCAST \
--cap-add=NET_RAW \
--net=host \
--env-file=.env \
peterweissdk/haproxy-keepalived
# Run the container using the provided Docker Compose and .env file
docker compose up -d
| Variable | Description | Example |
TZ: System Timezone - Europe/Berlin| Variable | Description | Example |
VRRP_INSTANCE: VRRP instance name - VI_1INTERFACE: Network interface - eth0STATE: Node state (MASTER/BACKUP) - MASTERPRIORITY: Node priority (1-255) - 100ROUTER_ID: Unique router ID - 50VIRTUAL_IPS: Virtual IP address - 192.168.1.100/24UNICAST_SRC_IP: Source IP for unicast - 192.168.1.11UNICAST_PEERS: Peer IP address - 192.168.1.12| Variable | Description | Example |
PROTOCOL_DEFAULT: Default protocol - tcpTIMEOUT_CLIENT_DEFAULT: Client timeout (seconds) - 10TIMEOUT_CONNECT_DEFAULT: Timeout, connect to a backend server (seconds) - 5TIMEOUT_SERVER_DEFAULT: Server timeout (seconds) - 10| Variable | Description | Example |
NAME_FRONTEND: Frontend name - ha-frontendPORT_FRONTEND: Listen port - 5001PROTOCOL_FRONTEND: Frontend protocol - tcpOPTION_FRONTEND: Frontend options - tcplogDEFAULT_BACKEND: Default backend name - ha-backend| Variable | Description | Example |
NAME_BACKEND: Backend name - ha-backendPROTOCOL_BACKEND: Backend protocol - tcpOPTION_BACKEND: Backend options - tcp-checkBALANCE_BACKEND: Server scheduling - roundrubin| Variable | Description | Example |
NAME_SERVER1: Backend name - backend-server1IP_SERVER1: Server IP address - 192.168.1.21PORT_SERVER1: Listen port - 6001NAME_SERVER2: Backend name - backend-server2IP_SERVER2: Server IP address - 192.168.1.22PORT_SERVER2: Listen port - 6002# Clone the repository
git clone https://github.com/peterweissdk/haproxy-keepalived.git
# Build the image
cd haproxy-keepalived
docker build -t haproxy-keepalived .
.
āāā conf/
ā āāā haproxy/
ā ā āāā haproxy.cfg_tpl
ā āāā keepalived/
ā ā āāā keepalived.conf_tpl
ā āāā supervisor/
ā āāā haproxy.ini
ā āāā keepalived.ini
āāā .env
āāā Dockerfile
āāā docker-entrypoint.sh
āāā supervisord.conf
āāā healthcheck.sh
āāā LICENSE
āāā README.md
The container includes built-in health checks for both HAProxy and Keepalived services. Monitor the status using:
docker inspect --format='{{json .State.ExitCode}}' <container_name>
View the Docker health check logs with the following command:
docker inspect --format='{{json .State.Health}}' <container_name>
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or need support, please file an issue on the GitHub repository.
This project is licensed under the GNU GENERAL PUBLIC LICENSE v3.0 - see the LICENSEā file for details.
Content type
Image
Digest
sha256:4d27ebbd4ā¦
Size
263 Bytes
Last updated
3 months ago
docker pull peterweissdk/haproxy-keepalived:sha256-21bb67db74a930eec704f2b823fda1bad8c8173d1f4733ebbbd114667b9c239e.sig