简体   繁体   English

如何在docker pull之前从不安全的注册表中检查图像的压缩大小?

[英]How to check compressed size of image from insecure registry before docker pull?

There are ways to check compressed image size before pulling from Docker Hub, but in order to do the same for an insecure/domain registry, how can I check the download size before pull?有多种方法可以在从 Docker Hub 拉取之前检查压缩图像的大小,但是为了对不安全/域注册表执行相同的操作,如何在拉取之前检查下载大小?

While doing a pull, I can see size of each layer being downloaded like this, which I can sum up to find total size.在进行拉动时,我可以看到像这样下载的每一层的大小,我可以总结一下以找到总大小。

7595c8c21622: Already exists
d13af8ca898f: Already exists
70799171ddba: Already exists
b6c12202c5ef: Already exists
ef50ae158fa8: Downloading [===============>                                   ]  74.18MB/239.3MB
e5665f29b73a: Downloading [=>                                                 ]  95.26MB/2.741GB
780c121f1da3: Downloading [========>                                          ]  75.27MB/462.5MB
5fc49bebd483: Waiting
592ff9f385a7: Waiting
80a3934684b4: Waiting
b523362dbfaa: Waiting
3bf96686ba27: Waiting
dd64f3b98c5f: Waiting
937238fb3569: Waiting
c39efc826c40: Waiting

But I would like to know beforehand what would be the total download size.但我想事先知道下载的总大小是多少。

Docker pushes a manifest file for each image on the registry, containing checksum, size and misc info, which all download clients use, in order to pull layers. Docker 为注册表上的每个映像推送一个清单文件,其中包含所有下载客户端都使用的校验和、大小和其他信息,以便拉取层。

Given your registry/image name, you can inspect the manifest file, sum up the sizes of each layer to get the total download size.给定您的注册表/图像名称,您可以inspect清单文件,总结每一层的大小以获得总下载大小。

First, enable Docker's experimental CLI features.首先,启用 Docker 的实验性 CLI 功能。

  1. To temporarily enable:暂时启用:

    export DOCKER_CLI_EXPERIMENTAL=enabled

  2. Make it permanent:使其永久化:

    Add "experimental": "enabled" in ~/.docker/config.json~/.docker/config.json添加"experimental": "enabled"

Check size:检查尺寸:

docker manifest inspect --insecure -v <registry_or_domain>/<image_name> | grep size | awk -F ':' '{sum+=$NF} END {print sum}' | xargs printf "%f\n" | numfmt --to=iec

printf formats the scientific notation of size (like 3e+09) to a float, which numfmt can parse. printf将大小的科学记数法(如 3e+09) numfmt为浮点数, numfmt可以解析它。

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

相关问题 如何使用最新的 Kubernetes 从不安全的私有注册表中提取 docker 映像 - How to pull docker image from a insecure private registry with latest Kubernetes Kube.netes 从不安全的 docker 注册表中拉取 - Kubernetes pull from insecure docker registry 无法从 Docker 本地不安全注册表中提取映像:http:服务器向 HTTPS 客户端提供 HTTP 响应 - Failed to pull image from Docker local insecure registry: http: server gave HTTP response to HTTPS client 让docker从kubernetes内部不安全的注册表中提取图像 - Have docker pull images from an insecure registry inside kubernetes Kubernetes 从私有不安全注册表中提取图像失败 - Kubernetes pull image from private insecure registry fails 如何在rancher服务中提取本地不安全的注册表映像? - How do I pull a local insecure registry image in a rancher service? docker pull / push无法使用不安全的注册表 - docker pull/push not working with insecure registry 如何从Docker注册表中提取容器映像以部署Azure容器 - How to pull container image from docker registry to deploy azure container Pulumi - 如何从私有注册表中提取 docker 镜像? - Pulumi - how to pull a docker image from a private registry? 如何使用 golang 从自定义 docker 注册表中提取图像? - How to pull image from custom docker registry with golang?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM