Dockerfile构建httpd镜像(yum方式)
1、建立工作目录
[root@docker ~]# mkdir httpd
[root@docker ~]# cd httpd
2、编写Dockerfile文件
[root@docker httpd]# vim Dockerfile
FROM centos:7
MAINTAINER Crushlinux <crushlinux@163.com>
RUN yum -y install httpd
RUN echo "crushlinux" >/var/www/html/index.html
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 80
CMD ["httpd","-DFOREGROUND"]
3、构建镜像
[root@docker httpd]# docker build -t httpd:new .
[root@docker httpd]# docker images httpd
4、测试容器
[root@docker httpd]# docker run -d -p 8001:80 --name httpd-test --restart=always httpd:new
5、浏览器访问测试:http://192.168.100.131:8001