当前位置:网站首页>如何使用“COPY –link”加速 Docker 构建和优化缓存
如何使用“COPY –link”加速 Docker 构建和优化缓存
2022-07-29 10:52:00 【mikes zhang】
COPY --link是一个新的BuildKit功能,可以大大加速您的 Docker 镜像构建。它通过将文件复制到不依赖于其前身存在的独立图像层中来工作。您可以在系统上不存在基本图像的情况下向图像添加新内容。
此功能于 2022 年 3 月作为Buildx v0.8的一部分添加。它包含在 Docker CLI 版本 20.10.14中,因此如果您正在运行最新版本,您应该已经可以访问。
在本文中,我们将展示它的–link作用并解释它是如何工作的。我们还将研究一些不应该使用它的情况。
什么是“–链接”?
link是现有 DockerfileCOPY指令的新可选参数。它通过在您每次使用它时创建一个新的快照层来改变副本的工作方式。
常规COPY语句将文件添加到 Dockerfile 中它们之前的层。该层的内容需要存在于您的磁盘上,以便新内容可以合并到:
FROM alpine
COPY my-file /my-file
COPY another-file /another-file
上面的 Dockerfile 复制my-file到上一个命令生成的层中。指令后FROM,图像由 Alpine 的内容组成:
bin/
dev/
etc/
...
第一COPY条指令生成一个图像,其中包括来自 Alpine 的所有内容以及my-file文件:
边栏推荐
- How to realize the function of adding watermark
- 从零开始Blazor Server(3)--添加cookie授权
- 使用 RTCGA 临床数据进行生存分析
- 若依集成minio实现分布式文件存储
- 报表控件FastReport与StimulSoft功能对比
- Why use markdown to write?
- GPO:在 Start/Logon 中使用 PowerShell 脚本
- Achieve the effect of a menu tab
- 2022cuda summer training camp day3 practice
- Kunlunbase instruction manual (I) quick installation manual
猜你喜欢
Kunlunbase instruction manual (IV) real time synchronization of data from Oracle to kunlunbase
QT基本工程的解析
leetcode-位运算
会议OA项目(五)---- 会议通知、反馈详情
牛客网刷题
How to synchronize when the primary and sub warehouses are modified?
VMWare:使用命令更新或升级 VMWare ESXi 主机
基于flask写的一个小商城mall项目
若依如何实现添加水印功能
Drawing box and ellipse of WPF screenshot control (IV) "imitating wechat"
随机推荐
Conference OA project - my approval
若依如何实现添加水印功能
建议收藏丨sql行转列的一千种写法!!
LeetCode_ 278_ First wrong version
Alibaba architects spent a year sorting out the "Lucene advanced document", and you are also a big factory employee!
数据可视化设计指南(信息图表篇)
Hutool日期时间
Roots of equations in R language dichotomy and Newton iteration
DNS协议、ICMP协议、NAT技术
Leetcode binary tree series -- 144. Preorder traversal of binary trees
判断两个对象的值是否都相等
R语言 使用数据集 veteran 进行生存分析
Data office system
Achieve the effect of a menu tab
Discussion on the application of arcing smart electricity in elderly care institutions
Svn revision keyword
正则表达式匹配网址
Kunlunbase instruction manual (II) best practices for peer-to-peer deployment
WPF 截图控件之绘制方框与椭圆(四) 「仿微信」
A tour of grp:04 - GRP unary call unary call