首先需要制作此次实验的基础镜像: 1. Dockerfile的编写: mkdir dockerfile && cd dockerfile vim Dockerfile #注意: Dockerfile的文件名首字母要大写 FROM alpine:latest
MAINTAINER "ZCF zcf@zczf.com"
ENV NGX_DOC_ROOT="/var/lib/nginx/html" HOSTNAME="" IP="" PORT="" INDEX_PAGE="" RUN apk --no-cache add nginx && mkdir -p ${NGX_DOC_ROOT}/shop /run/nginx
COPY chk.html ${NGX_DOC_ROOT} COPY entrypoint.sh /bin
CMD ["/usr/sbin/nginx","-g","daemon off;"] #定义启动nginx服务为前端启动, -g:是global段,中修改daemon off; ENTRYPOINT ["/bin/entrypoint.sh"] #将CMD的命令,作为参数传递给/bin/entrypoint.sh 脚本.
#准备Dockerfile配套的基础文件: 1) 启动容器时,执行的脚本文件: entrypoint.sh vim entrypoint.sh #!/bin/sh
echo "
WELCOME TO ${HOSTNAME:-www.zcf.com} WEB SITE | date | hostname | hostname -i | -${YOU_INFO:-v1}- |" >