Dockerfile构建httpd
首先安装Docker依赖环境
yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum makecache fast
安装Docker
yum -y install docker-ce
编辑Dockerfile
vim Dockerfile
FROM centos:7 RUN yum -y install httpd RUN mkdir -p /var/www/html RUN echo "123" >/var/www/html/index.html CMD ["httpd","-DFOREGROUND"]
执行Dockerfile
docker build -t httpd:1 ./

查看Docker镜像
docker images

基于镜像构建容器
docker run --name httpd -d -p 80:80 httpd:1

查看容器
docker ps -a

浏览器访问


浙公网安备 33010602011771号