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;"]