[root@localhost haproxyalpine]# tree . ├── Dockerfile └── files ├── haproxy-2.5.0.tar.gz ├── haproxycfg.sh ├── install.sh └── sysctl.confDockerfile
[root@localhost haproxyalpine]# cat Dockerfile FROM alpine LABEL MAINTAINER "luochuran 1225514226@qqq.com" ENV version 2.5.0 ADD files/haproxy-${version}.tar.gz /tmp/ ADD files/install.sh /tmp/ ADD files/haproxycfg.sh /tmp/ ADD files/sysctl.conf /tmp/ RUN /tmp/install.sh ENTRYPOINT /tmp/haproxycfg.sh安装haproxy脚本
[root@localhost haproxyalpine]# cat files/install.sh #!/bin/sh sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories apk update adduser -S -H -s /sbin/nologin haproxy addgroup haproxy apk add --no-cache -U make gcc pcre-dev bzip2-dev openssl-dev elogind-dev libc-dev dahdi-tools dahdi-tools-dev libexecinfo libexecinfo-dev ncurses-dev zlib-dev zlib cd /tmp/haproxy-2.5.0 make TARGET=linux-musl USE_OPENSSL=1 USE_ZLIB=1 USE_PCRE=1 make install PREFIX=/usr/local/haproxy cp haproxy /usr/sbin/ mkdir /etc/haproxy apk del gcc make rm -rf /tmp/haproxy-2.5.0/ /tmp/install.sh配置文件
[root@localhost haproxyalpine]# cat files/haproxycfg.sh #!/bin/sh cat > /etc/haproxy/haproxy.cfg <> /etc/haproxy/haproxy.cfg < 制作镜像 [root@localhost haproxyalpine]# ls Dockerfile files [root@localhost haproxyalpine]# docker build -t haproxy:v3.0 . [root@localhost haproxyalpine]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE haproxy v3.0 bb2af435dd0d 9 seconds ago 85.1MB启动容器[root@localhost ~]# docker run -d --name apache 1225514226/httpd:v1.0 [root@localhost ~]# docker run -d --name nginx 1225514226/nginx:v0.3 [root@localhost haproxyalpine]# docker run -d --name haproxy -p 80:80 -e RSs="172.17.0.4 172.17.0.5" haproxy:v3.0 f9d6e427f11d65eb0117835dafdc490ef043e301a8af3f71888967e2969acbac [root@localhost haproxyalpine]# docker ps ConTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f9d6e427f11d haproxy:v3.0 "/bin/sh -c /tmp/hap…" 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp haproxy d824b80e750e 1225514226/nginx:v0.3 "/usr/local/nginx/sb…" 18 minutes ago Up 18 minutes nginx daa852698965 1225514226/httpd:v1.0 "/usr/local/apache/b…" 20 minutes ago Up 20 minutes 80/tcp apache浏览器访问测试欢迎分享,转载请注明来源:内存溢出
评论列表(0条)