docker-compose配置

这篇博客介绍了如何利用Docker Compose快速部署分布式应用,详细讲述了如何基于rhel7镜像封装带有httpd服务的镜像,创建并测试镜像,然后通过docker-compose配置haproxy集群,实现负载均衡。
摘要由CSDN通过智能技术生成

Docker Compose 是 Docker 官方编排(Orchestration)项目之一,负责快速的部署分布式应用。

这是我的docker images(local):
上面的v1就是我封装的httpd

这里写图片描述

先用rhel7镜像封装一个有httpd的服务镜像:

这里写图片描述

Dockerfile文件:
FROM rhel7
MAINTAINER oo
ENV HOSTNAME web1
EXPOSE 80
COPY dvd.repo /etc/yum.repos.d/dvd.repo
RUN rpmdb --rebuilddb && yum install -y httpd && yum clean all
COPY web/index.html /var/www/html/index.html
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
dvd.repo文件:
[dvd]
name=rhel7.3
baseurl=http://172.25.5.250/rhel7.3
gpgcheck=0


[docker]
name=docker
baseurl=http://172.25.5.250/pub/yum
gpgcheck=0
创建images:rhel7:v1
[root@foundation5 test]# docker build -t rhel7:v1 .
Sending build context to Docker daemon 4.608 kB
Step 1/8 : FROM rhel7
 ---> 0a3eb3fde7fd
Step 2/8 : MAINTAINER oo
 ---> Using cache
 ---> 45391a65a7b8
Step 3/8 : ENV HOSTNAME web1
 ---> Using cache
 ---> 60580fc7e680
Step 4/8 : EXPOSE 80
 ---> Using cache
 ---> d1277e1311f8
Step 5/8 : COPY dvd.repo /etc/yum.repos.d/dvd.repo
 ---> Using cache
 ---> cbaf2b135bdb
Step 6/8 : RUN rpmdb --rebuilddb && yum install -y httpd && yum clean all

------太长省略

Step 7/8 : COPY web/index.html /var/www/html/index.html
 ---> d18df941f38b
Removing intermediate container 198b410dc345
Step 8/8 : CMD /usr/sbin/httpd -D FOREGROUND
 ---> Running in f1e8ee77bee5
 ---> 91fc7d1a2364
Removing intermediate container f1e8ee77bee5
Successfully built 91fc7d1a2364
生成的镜像:

这里写图片描述

测试httpd:
[root@foundation5 test]# docker run -d --name vm1 rhel7:v1 
b0661d7e92fc495ada22c73e17648c3be33ae80fbba7de2c3882d3c5a1beff61
[root@foundation5 test
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值