[英]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 功能。
To temporarily enable:暂时启用:
export DOCKER_CLI_EXPERIMENTAL=enabled
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.