keepalived 官网:https://keepalived.org/index.html
docker-keepalived: https://github.com/osixia/docker-keepalived
镜像仓打好的latest:https://hub.docker.com/r/osixia/keepalived/tags
手动打最新keepalived 镜像
dockerfile: https://github.com/osixia/docker-keepalived/blob/master/image/Dockerfile
修改version,换apk源,信任
# Use osixia/light-baseimage
# sources: https://github.com/osixia/docker-light-baseimage
FROM osixia/light-baseimage:alpine-0.1.6-dev
# Keepalived version
ARG KEEPALIVED_VERSION=2.0.20
# Download, build and install Keepalived
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.16/main" > /etc/apk/repositories \
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories \
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/latest-stable/main" >> /etc/apk/repositories \
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/latest-stable/community" >> /etc/apk/repositories \
&& echo "https://mirror.tuna.tsinghua.edu.cn/alpine/edge/testing" >> /etc/apk/repositories
RUN apk --no-cache --allow-untrusted add \
autoconf \
curl \
gcc \
ipset \
ipset-dev \
iptables \
iptables-dev \
libnfnetlink \
libnfnetlink-dev \
libnl3 \
libnl3-dev \
make \
musl-dev \
openssl \
openssl-dev \
&& curl -o keepalived.tar.gz -SL http://keepalived.org/software/keepalived-${KEEPALIVED_VERSION}.tar.gz \
&& mkdir -p /container/keepalived-sources \
&& tar -xzf keepalived.tar.gz --strip 1 -C /container/keepalived-sources \
&& cd container/keepalived-sources \
&& ./configure --disable-dynamic-linking \
&& make && make install \
&& cd - && mkdir -p /etc/keepalived \
&& rm -f keepalived.tar.gz \
&& rm -rf /container/keepalived-sources \
&& apk --no-cache del \
autoconf \
gcc \
ipset-dev \
iptables-dev \
libnfnetlink-dev \
libnl3-dev \
make \
musl-dev \
openssl-dev
# Add service directory to /container/service
ADD service /container/service
# Use baseimage install-service script
# https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/install-service
RUN /container/tool/install-service
# Add default env variables
ADD environment /container/environment/99-default
源码打镜像
https://keepalived.org/software/keepalived-2.2.7.tar.gz
./configure OPTIONS
make
make docker
Alternatively there is a very useful github project that was maintained
by osixia for building a docker container with keepalived.
To use, run the following:
git clone https://github.com/osixia/docker-keepalived.git
cd docker-keepalived
make build
docker run --name keepalived --cap-add=NET_ADMIN --net=host \
--env KEEPALIVED_INTERFACE=eth0 -d osixia/keepalived:1.3.5 \
# or whatever version of keepalived you have