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]
b0661d7e92fc495ada22c73e17648c3be33ae80fbba7de2c3882d3c5a1beff61
[root@foundation5 test