A high-performance, ultra-lightweight Keepalived container based on Alpine Linux 3.23. This image is stripped of heavy frameworks (no Python, no Osixia-bloat) to provide a minimal footprint and maximum security.
- Ultra-lightweight: ~15MB total size (compared to 100MB+ for Python-based alternatives).
- Modern Engine: Built on Alpine 3.23 with Keepalived 2.3.4.
- Hybrid Configuration: Supports both automatic generation via Environment Variables and custom configuration via Volume mounting.
- Real-time Logging: Logs are natively redirected to
stdout/stderrfor seamless integration withdocker logs. - CI/CD Ready: Designed for automated builds via GitHub Actions and GHCR.
Perfect for standard Master/Backup setups. Configuration is generated automatically at startup.
services:
keepalived:
image: ghcr.io/your-username/keepalived:latest
cap_add:
- NET_ADMIN
- NET_RAW
network_mode: host # Required for VRRP
environment:
- STATE=MASTER
- MYIF=eno1 # Recommended: prioritized over INTERFACE
- VIRTUAL_IP=192.168.1.100/24
- PRIORITY=101
- ROUTER_ID=51If you need complex features like Unicast Peers, multiple VRRP instances, or health-check scripts, mount your own configuration.
services:
keepalived:
image: ghcr.io/your-username/keepalived:latest
cap_add:
- NET_ADMIN
- NET_RAW
network_mode: host
volumes:
- ./my-keepalived.conf:/etc/keepalived/keepalived.conf:ro| Variable | Description | Default |
|---|---|---|
STATE |
Initial VRRP state (MASTER or BACKUP) |
MASTER |
MYIF |
Primary network interface (takes precedence over INTERFACE) |
- |
INTERFACE |
Fallback network interface to bind the VRRP instance | eth0 |
VIRTUAL_IP |
The VIP address (CIDR format recommended) | 192.168.1.1 |
PRIORITY |
VRRP priority value (Higher value = Higher priority) | 100 |
ROUTER_ID |
Unique VRRP Router ID (0-255) | 51 |
docker build -t my-keepalived .The image is built and pushed automatically on every tag or push to main. The build process uses multi-stage builds to ensure the final image contains no build-time dependencies.
docker logs -f keepaliveddocker exec -it keepalived cat /etc/keepalived/keepalived.confdocker exec -it keepalived ip addr showThis project is licensed under the MIT License - see the LICENSE file for details.