zoukankan      html  css  js  c++  java
  • 减少Docker镜像层的数量

    减少Docker镜像层的数量
    Dokcerfile中的RUN、COPY和ADD命令才会创建镜像层,因此减少Docker镜像层的数量就是要减少这几个命令的次数,特别是RUN命令的次数。

    在安装工具时可以在一句命令中安装多个工具:

    正例:

    apt-get install -y git curl

    反例:

    apt-get install -y git
    apt-get install -y curl

    用&&拼接多个命令:

    正例:
    RUN apt-get update && apt-get upgrade -y && apt-get install -y git curl

    反例:
    RUN apt-get update
    RUN apt-get upgrade -y
    RUN apt-get install -y git curl

    用来在拼接多个命令时换行,增加可读性

    RUN curl -fsSL https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$(dpkg --print-architecture) -o /sbin/tini
    && curl -fsSL https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$(dpkg --print-architecture).asc -o /sbin/tini.asc
    && gpg --no-tty --import ${JENKINS_HOME}/tini_pub.gpg
    && gpg --verify /sbin/tini.asc
    && rm -rf /sbin/tini.asc /root/.gnupg
    && chmod +x /sbin/tini

    -----------------------------------------------------------------------------
    交流QQ号:1175372067
    电话:18551717618(同微信)
    元几科技.软件3部
    迈开步伐去探索
    南京元几科技有限公司
    元几社区: https://www.cnblogs.com/colin-vio
    元几官网: http://www.yuanji.tech
    -----------------------------------------------------------------------------
  • 相关阅读:
    kubeadm升级证书-集群已GG
    匿名内部类
    JAVA中Integer的==和equals注意
    编写高效优雅安全Java程序的常见原则
    图解排序算法(二)之希尔排序
    String常见问题
    ActiveMQ 2
    消息中间件概述和AaciveMQ 1
    类加载器-5
    使用MyBatis编写Dao的两种语法
  • 原文地址:https://www.cnblogs.com/colin-vio/p/14421231.html
Copyright © 2011-2022 走看看