简体   繁体   English

Google Cloud Container Registry - 检查图像大小

[英]Google Cloud Container Registry - Check image size

I sent a docker file for Google Cloud Build.我为 Google Cloud Build 发送了一个 docker 文件。 The build was created successfully.构建已成功创建。

The artifact URL is:神器URL是:

gcr.io/XXX/api/v1:abcdef017e651ee2b713828662801b36fc2c1 gcr.io/XXX/api/v1:abcdef017e651ee2b713828662801b36fc2c1

How I can check the image size?如何检查图像大小? (MB\GB) (MB\GB)

There isn't API for this.没有 API 这个。 But I have a workaround, this Linux command line但我有一个解决方法,这个 Linux 命令行

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  https://gcr.io/v2/XXX/api/v1/manifests/abcdef017e651ee2b713828662801b36fc2c1 2>/dev/null | \
  jq ".layers[].size" | \
  awk '{s+=$1} END {print s}'

Detail line by line逐行详细

  1. Create a curl with a secure token from the GCLOUD CLI从 GCLOUD CLI 创建一个带有安全令牌的 curl
  2. Get the image manifest, which describe all the layers and their size获取图像清单,它描述了所有层及其大小
  3. Get only the layers' sizes仅获取层的大小
  4. Sum the sizes总结大小

-> Result is in Byte. -> 结果以字节为单位。

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

相关问题 谷歌云:Artifact Registry 与 Container Registry - Google Cloud: Artifact Registry vs Container Registry Google Cloud Container Registry/Artifact Registry 权限 - Google Cloud Container Registry/Artifact Registry Permissions Google Cloud Container Registry 子目录创建 - Google Cloud Container Registry Subdirectory Create 如何在 CLI 中按图像大小顺序列出 Google Container Registry 中已发布的容器图像 - How to list the published container images in the Google Container Registry in a CLI in image size order Docker 图像无法在 Google Container Registry 上构建 - Docker image fails to build on Google Container Registry 检查谷歌云中的实体大小 - Check Entity Size in Google cloud 使用谷歌云代码在 vscode 中指定本地 docker 容器注册表 - Specifying local docker container registry in vscode using Google Cloud code Google Cloud Artifact Registry Docker 具有虚拟大小的图像的存储定价 - Google Cloud Artifact Registry Docker Storage pricing for images with Virtual size 如何使用 yaml 文件将 Google Cloud Build 上的构建发布到 Google Container registry - How to publish a build on Google Cloud Build to Google Container registry using yaml file 谷歌云容器注册表错误:“无法触发构建:请求包含无效参数。” - google cloud container registry error: "Failed to trigger build: Request contains an invalid argument."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM