Build the apache container
1. Create a file
mkdir /opt/apache
cd /opt/apache/
2. Write a Dockerfile
vim Dockerfile
#基础镜像
FROM centos:7
#维护镜像人员信息
MAINTAINER Ruyi
#镜像操作指令安装软件
RUN yum -y update
RUN yum -y install httpd
#开启80端口
EXPOSE 80
#复制网站首页信息
ADD index.html /var/www/html/index.html
#将执行脚本复制到镜像中
ADD run.sh /run.sh
RUN chmod 755 /run.sh
#启动容器时执行脚本
CMD ["/run.sh"]
3. Write the startup file
vim run.sh
#!/bin/bash
rm -rf /run/htttpd/*
exec /usr/sbin/apachectl -D FOREGROUND
4. Write the homepage file of the webpage
echo "ruyi" >> index.html
5. Establish a mirror
docker build -t httpd:centos .
6, the designated port to establish a container
docker run -d -p 1234:80 httpd:centos
7. Log in to the designated port to view the interface
http://192.168.199.40:1234/