基于centos制作
下载
网址:https://src.fedoraproject.org/repo/pkgs/haproxy/
准备文件
[root@localhost centos]# ls
Dockerfile haproxy-2.0.13.tar.gz haproxy.cfg run.sh
dockerfile内容
[root@localhost centos]# cat Dockerfile
#docker image is haproxy-2.0.13
FROM centos:7.7.1908
LABEL mail=timerovers@163.com
ENV TIME_ZOME Asia/Shanghai
ENV LANG=zh_CN.utf8
ENV HAPROXY haproxy-2.0.13
ADD $HAPROXY.tar.gz /usr/local/src/
RUN yum -y install gcc gcc-c++ make glibc glibc-devel pcre pcre-devel \
openssl openssl-devel systemd-devel zip unzip zlib zlib-devel \
&& rm -rf /etc/localtime \
&& ln -sf /usr/share/zoneinfo/${TIME_ZOME} /etc/localtime \
&& yum -y install kde-l10n-Chinese \
&& yum -y reinstall glibc-common \
&& localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 \
&& echo "LANG="zh_CN.utf8"" > /etc/locale.conf \
&& source /etc/locale.conf \
&& yum clean all
RUN groupadd -r haproxy && useradd -g haproxy -M -s /sbin/nologin haproxy
RUN cd /usr/local/src/$HAPROXY \
&& make ARCH=x86_64 TARGET=linux-glibc USE_OPENSSL=1 USE_ZLIB=1 \
USE_SYSTEMD=1 USE_CPU_AFFINITY=1 PREFIX=/usr/local/haproxy \
&& make install PREFIX=/usr/local/haproxy \
&& cp haproxy /usr/sbin/ && mkdir /usr/local/haproxy/etc
COPY haproxy.cfg /usr/local/haproxy/etc/
ADD run.sh /usr/bin
EXPOSE 80 443
CMD ["/usr/bin/run.sh"]
配置文件以及启动命令内容
配置文件按照自己需求配置
[root@localhost centos]# cat haproxy.cfg
global
log 127.0.0.1 local2 info
#chroot /usr/local/haproxy #工作目录
pidfile /usr/local/haproxy/etc/haproxy.pid
maxconn 4000
nbproc 1
user haproxy
group haproxy
daemon
defaults
log global
option dontlognull
timeout connect 10s
timeout client 10s
timeout server 10s
timeout check 10s
maxconn 60000
retries 3
listen admin_stats
bind 0.0.0.0:8089
stats enable
mode http
log global
stats uri /stats
stats realm Haproxy\ Statistics
stats auth admin:admin
stats hide-version
stats admin if TRUE
stats refresh 30s
[root@localhost centos]# cat run.sh
#!/bin/bash
haproxy -f /usr/local/haproxy/etc/haproxy.cfg
tail -f /usr/local/haproxy/etc/haproxy.cfg
大小
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
haporxy-centos 2.0.13 e2b2f22d0b39 38 seconds ago 450MB