zoukankan      html  css  js  c++  java
  • docker分阶段构造nginx镜像

    FROM centos:7 as build
    ADD nginx-1.19.6.tar.gz /usr/local/src
    
    # change dir to /usr/local/src/nginx-1.19.6
    WORKDIR /usr/local/src/nginx-1.19.6
    
    # running required command
    RUN yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel libxslt-devel gd gd-devel GeoIP GeoIP-devel pcre pcre-devel && useradd -M -s /sbin/nologin nginx && ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module &> /dev/null && make &> /dev/null &> /dev/null && make install &> /dev/null && rm -fr /usr/local/src/nginx-*
    
    FROM  centos:7
    COPY --from=build /usr/local/nginx /usr/local/nginx
    EXPOSE 80 443
    VOLUME ["/usr/local/nginx/html"]
    CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]

    分阶段构造docker镜像,可显著降低镜像大小

  • 相关阅读:
    1.8新特性
    线程池
    微服务简介
    缓存三大问题
    Redis分布式锁的正确实现方式
    【java-10&11&12】java语言(Hello World相关)
    【postman】postman 安装失败
    【java-04-09集】JDK的下载和安装&配置环境变量(临时和永久)&命令行方式
    【ISTQB】TM&TA&TTA区别
    【git】学习地址
  • 原文地址:https://www.cnblogs.com/wt11/p/14311254.html
Copyright © 2011-2022 走看看