#: Download image and initialize the system the root @ Ubuntu: ~ # Docker pull CentOS #: Create Directory the root @ Ubuntu: / opt # mkdir dockerfile / {Web / {Nginx, Tomcat, JDK, a Apahce}, System / {Linux, Ubuntu, }} RedHat - pv root @ Ubuntu: / opt dockerfile # cd / Web / nginx / #: write dockerfile root @ Ubuntu: / opt / dockerfile / Web / nginx dockerfile # # vim: the first letter must be capitalized, fixed format FROM CentOS: Latest MAINTAINER XueBin.Ma 316 428 921 @ qq.com ENV name nginx RUN yum install vim iotop gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel zlib-devel net-tools libevent libevent-devel systemd-devel -y ADD nginx-1.16.1.tar.gz /usr/local/src RUN cd /usr/local/src/nginx-1.16.1 && ./configure --prefix=/apps/nginx && make && make install RUN mkdir /data/html/nginx -pv && echo 1.txt > /data/html/nginx/index.html && useradd -r -u 66 nginx ADD nginx.conf /apps/nginx/conf/nginx.conf RUN chownNginx.nginx -R & lt / Apps / Nginx / * && chown -R & lt nginx.nginx / Data / HTML / * the RUN LN -sv / Apps / Nginx / sbin / Nginx / usr / bin EXPOSE 80 443 the CMD [ "Nginx"] # : copy source package and configuration files to the catalog root @ ubuntu: / opt / dockerfile / Web / LS # Nginx Dockerfile Nginx-1.16.1.tar.gz nginx.conf #: modify the configuration file root @ ubuntu: / opt / dockerfile / Web / Nginx # Vim nginx.conf daemon OFF; #: mirrored the root @ Ubuntu: / opt / dockerfile / Web / Nginx Nginx # -t-Docker Build 1.0: V1 / opt / dockerfile / Web / Nginx / #: run the test root @ ubuntu: / opt / dockerfile / web / nginx # docker run -d -it -p 80:80 nginx-1.0: v1
Export mirror the root @ Ubuntu: / opt / dockerfile / Web / Save nginx- Docker Nginx # 1.0 :. V1> / usr / local / the src / Nginx the tar .gz imported image [the root @ localhost the src] # Docker Load <Nginx. The tar .gz