简体   繁体   English

docker 如何加载差异图像

[英]How docker load a diff image

I know docker save can save a image to tar and use docker load to reload a image.我知道docker save可以将图像保存到 tar 并使用docker load重新加载图像。

For example:例如:

I have a Machine A and B. B can't connect hub .我有一台机器 A 和 B。B无法连接集线器 A is image:latest and B is image:base. A 是图像:最新,B 是图像:基础。

I have to save multi image in A as some tar file , but the tar files are too big to transfer.我必须将A 中的多图像保存为某个 tar 文件,但 tar 文件太大而无法传输。

Can I save the diff between tags or image ids in A and load the diff in B?我可以保存在标签或图像ID之间的差异和B中加载差异

Not save the whole image which help update patch much more smaller.不保存整个图像,这有助于将补丁更新得更小。

This isn't possible using standard Docker tooling.使用标准 Docker 工具无法做到这一点。 The only option docker save takes is an option to write to a file rather than to stdout, and it always contains all parent layers (and base images). docker save的唯一选项是写入文件而不是标准输出的选项,并且它始终包含所有父层(和基础图像)。

If your only problem is transferring the images, consider either techniques to reduce the image size (for example, use a multi-stage image to not include build-time dependencies in the final image) or using tools like split (1) to break the tar file into smaller parts.如果您唯一的问题是传输映像,请考虑使用减少映像大小的技术(例如,使用多阶段映像在最终映像中不包含构建时依赖项)或使用split (1) 之类的工具来破坏tar 文件分成更小的部分。

I believe the docker save tar file output is the same as the "Export an image" API call .我相信docker save tar 文件输出与“导出图像”API 调用相同 It might be possible to manually edit that tar file to delete layers, and there might be tools out there that do this.可能可以手动编辑该 tar 文件以删除图层,并且可能有工具可以执行此操作。 (This is not a particularly mainstream path, though; I've looked into it several years ago but not done it myself, and occasionally see tools mentioned in infrequent SO answers.) (不过,这并不是一条特别主流的路径;我几年前研究过它,但自己没有做过,偶尔会看到很少见的 SO 答案中提到的工具。)

In between the standard behavior of docker pull and docker save only creating complete image chains, in principle there's no way to set up Docker so that you never only have the "top half" of an image but not the base layers below this.docker pulldocker save的标准行为之间,只创建完整的图像链,原则上没有办法设置 Docker,这样你就永远不会只有图像的“上半部分”,而没有下面的基础层。 Editing the docker save tar files by hand would violate this invariant.手动编辑docker save tar 文件将违反此不变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM