No1Lives4Ever
No1Lives4Ever

Reputation: 6883

Google Cloud Container Registry - Check image size

I sent a docker file for Google Cloud Build. The build was created successfully.

The artifact URL is:

gcr.io/XXX/api/v1:abcdef017e651ee2b713828662801b36fc2c1

How I can check the image size? (MB\GB)

Upvotes: 0

Views: 1871

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75910

There isn't API for this. But I have a workaround, this Linux command line

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
  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.

Upvotes: 1

Related Questions