Dockerfile是由一系列命令和参数构成的脚本,这些命令应用于基础镜像并最终建立一个新的镜像。它们简化了从头至尾的流程并极大的简化了部署工做。Dockerfile从FROM命令开始,紧接着跟随者各类方法,命令和参数。其产出为一个新的能够用于建立容器的镜像。nginx
使用如下的语法能够实现各类各样的镜像git
以https://dev.aliyun.com中的项目来讲github
一、通常做者都会存放这个image对应的Dockerfiledocker
二、咱们也能够直接使用Dockerfile来生成本身的nginx镜像bash
能够参考https://github.com/qq4311949/dockerfile-demo,有啥不对的,欢迎指正网络
#This is my first Dockerfile #Version 1.0 #Author: Maybe@qq.com #Base images FROM alpine #MAINTAINER MAINTAINER Maybe@qq.com #ADD ADD ./pkg/nginx-1.14.0.tar.gz /usr/local/src #WORKDIR WORKDIR /usr/local/src/nginx-1.14.0 #RUN RUN apk add --no-cache gcc g++ make zlib-dev pcre-dev openssl-dev --repository http://mirrors.aliyun.com/alpine/v3.8/main/ \ && addgroup www \ && adduser -s /sbin/nologin -D -G www -H www \ && ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module \ && make \ && make install \ && apk del gcc g++ make \ && rm -rf /usr/local/src/* COPY ./conf/nginx.conf /usr/local/nginx/conf/nginx.conf EXPOSE 80 443 CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]