Created
July 7, 2025 14:22
-
-
Save dtaivpp/bcecdb0d5a5367b49a77b71eb075526e to your computer and use it in GitHub Desktop.
A concise way to find the compressed size of a container without needing to pull it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Macro for finding the size of a container from any container registry,EG: mcr, gcp, or docker | |
# Example use: | |
# dockersize docker pull mcr.microsoft.com/devcontainers/universal:3 | |
# linux/amd64 140.70M | |
# linux/arm/v6 131.74M | |
# linux/arm/v7 129.97M | |
# linux/arm64/v8 132.15M | |
# Credit to ddelange from this thread: https://stackoverflow.com/a/73108928/4577237 | |
dockersize() { docker manifest inspect -v "$1" | jq -c 'if type == "array" then .[] else . end | select(.Descriptor.platform.architecture != "unknown")' | jq -r '[ ( .Descriptor.platform | [ .os, .architecture, .variant, ."os.version" ] | del(..|nulls) | join("/") ), ( [ ( .OCIManifest // .SchemaV2Manifest ).layers[].size ] | add ) ] | join(" ")' | numfmt --to iec --format '%.2f' --field 2 | sort | column -t ; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment