Skip to content

MarcelloPercoco/keepalived

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alpine Keepalived Ultra-Light

Docker Image Build License: MIT Alpine Version

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.


🚀 Features

  • 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/stderr for seamless integration with docker logs.
  • CI/CD Ready: Designed for automated builds via GitHub Actions and GHCR.

🛠 Usage & Deployment

1. Simple Mode (Environment Variables)

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=51

2. Advanced Mode (Custom File)

If 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

Configuration Reference (Tabella per il README)

⚙️ Configuration Reference

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

🏗 Build & Automation

Local Build

docker build -t my-keepalived .

GitHub Actions Integration

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.


Troubleshooting & Debugging

View real-time logs:

docker logs -f keepalived

Verify the active configuration generated by the entrypoint:

docker exec -it keepalived cat /etc/keepalived/keepalived.conf

Check network status and assigned VIPs:

docker exec -it keepalived ip addr show

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Maintained with ❤️ by [MarcelloPercoco]

About

Simple alpine based keepalived docker image

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors