本文重点内容:
- 编译生成nginx_accept_language_module镜像
- 容器启动后,docker logs没日志输出
- 多阶段编译,优化镜像大小
Dockerfile内容如下:
FROM daocloud.io/library/centos:7 as base
MAINTAINER nginx
RUN yum install -y epel-release
RUN yum install -y gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-server unzip make
ADD nginx-1.16.0.tar.gz /usr/local/ #nginx安装包(wget http://nginx.org/download/nginx-1.16.0.tar.gz)
RUN mkdir -p /usr/local/nginx/conf.d
WORKDIR /usr/local/nginx-1.16.0/
COPY master.zip /usr/local/nginx-1.16.0/
RUN unzip master.zip #nginx_accept_language_module安装包(wget --no-check-certificate https://github.com/max-l/nginx_accept_language_module/archive/master.zip)
RUN ./configure --add-module=/usr/local/nginx-1.16.0/nginx_accept_language_module-master --with-stream --prefix=/usr/local/nginx --group=nginx --user=nginx
RUN make && make install
ADD nginx.conf /usr/local/nginx/conf/nginx.conf
#多阶段编译,优化镜像大小
FROM daocloud.io/library/centos:7
WORKDIR /usr/local/nginx
COPY --from=base /usr/local/nginx ./
RUN useradd -s /sbin/nologin -M nginx && chown -R nginx.nginx /usr/local/nginx
ENV PATH=/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
RUN ln -sf /dev/stdout /usr/local/nginx/logs/access.log && ln -sf /dev/stderr /usr/local/nginx/logs/error.log #容器运行后,docker logs无日志输出的问题
EXPOSE 80
ENTRYPOINT ["nginx","-g","daemon off;"]
标签:module,RUN,language,--,accept,nginx,usr,local From: https://blog.51cto.com/u_11791718/6068682