在docker映像中具有图层的优点是什么? [英] what are the advantages of having layers in a docker image?

查看:78
本文介绍了在docker映像中具有图层的优点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个不同的Dockerfile。

Let's say I have two different Dockerfiles.


  1. 一个称为nudoc / my-base-image的图片:1.1

  1. Image one called nudoc/my-base-image:1.1

FROM ubuntu:16.10
COPY . /test.war


  • 图片二称为nudoc / my-testrun-image:1.1

  • Image two called nudoc/my-testrun-image:1.1

     FROM acme/my-base-image:1.1
     CMD /test/start.sh
    


  • 两者都有相同的图层。

    什么是在Docker映像中具有图层的优点是什么?

    Both have the layers in common.
    What are the advantages of having layers in a docker image? does it benefit from pulling from the registry?

    推荐答案

    亨利已经说过


    公用层仅下载一次且仅存储一次。因此,这对于下载以及存储都有好处。

    Common layers are downloaded only once and are stored only once. So this has benefits for download as well as storage.

    另外,如果创建命令允许,则构建映像将重用图层。这样可以减少构建时间。例如,如果您将文件复制到图像中,并且该文件与上一个版本中的文件相同,则旧层将被重用。有关更多详细信息,请参见编写dockerfile的最佳做法

    Additionaly building an image will reuse layers if the creating command allows. This reduces the build time. For example if you copy a file into your image and the file is the same as in the last build the old layer will be reused. See the best practices for writing dockerfiles for more details.

    这篇关于在docker映像中具有图层的优点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆