命令
# 创建目录
mkdir nginxroot
# 进入目录
cd nginxroot
# 生成首页文件
echo "nginx is running" >> index.html
# 创建dockerfile文件
vim Dockerfile
### dockerfile开始
FROM centos:centos7
MAINTAINER "xx@126.com"
RUN yum -y install wget
RUN wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
RUN yum -y install nginx
ADD index.html /usr/share/nginx/html/
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
EXPOSE 80
CMD /usr/sbin/nginx
### dockerfile结束
# 创建镜像
docker build -t centos7-nginx:v1 .
# 查看镜像
docker images
# 运行镜像
docker run -d -p 8081:80 centos7-nginx:v1
# 访问镜像
curl http://localhost:8081