[root@localhost haproxy]# tree . ├── Dockerfile └── files ├── haproxy-2.4.0.tar.gz ├── haproxycfg.sh ├── install.sh └── sysctl.confDockerfile
[root@localhost haproxy]# cat Dockerfile FROM alpine LABEL MAINTAINER="yyy 123456789@com" ENV version 2.4.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配置文件和安装脚本
[root@localhost files]# vim haproxycfg.sh [root@localhost files]# chmod +x haproxycfg.sh [root@localhost files]# cat haproxycfg.sh #!/bin/sh cat > /etc/haproxy/haproxy.cfg <> /etc/haproxy/haproxy.cfg < 测试 //创建镜像 [root@localhost ~]# docker build -t haproxy:v0.3 haproxy [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE haproxy v0.3 0140afce2d43 29 seconds ago 83.8MB haproxy v0.1 949e1a86fb6b 39 hours ago 578MB yzy0923/httpd v0.01 a88b702deaee 3 days ago 701MB busybox latest d23834f29b38 12 days ago 1.24MB alpine latest c059bfaa849c 2 weeks ago 5.59MB centos 8 5d0da3dc9764 2 months ago 231MB centos latest 5d0da3dc9764 2 months ago 231MB //创建容器 [root@localhost haproxy]# docker run -d --name haproxy -p 80:80 -e RSs="172.17.0.3 172.17.0.4" haproxy:v0.3 2e7cf1e4a7b627e1af648197515bf1cf4b80675d549ff283133e269b64829b63 [root@localhost haproxy]# docker run -d --name http httpd 2a9df974dc4ab3f5b0351c9dd1b36b60dbc5079d31d95404f92983bd7ce8518a [root@localhost haproxy]# docker run -d --name nginx nginx 7d6d2c004eb144d9375838806c0dee59c0b9f0dd3d067126bab35f0596debb08 [root@localhost haproxy]# docker ps ConTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7d6d2c004eb1 nginx "/docker-entrypoint.…" 54 seconds ago Up 52 seconds 80/tcp nginx 2a9df974dc4a httpd "httpd-foreground" about a minute ago Up about a minute 80/tcp http 2e7cf1e4a7b6 haproxy:v0.3 "/bin/sh -c /tmp/hap…" about a minute ago Up about a minute 0.0.0.0:80->80/tcp, :::80->80/tcp haproxy欢迎分享,转载请注明来源:内存溢出
评论列表(0条)