{"id":16514871,"url":"https://github.com/schnatterer/docker-image-size","last_synced_at":"2026-05-01T21:01:24.714Z","repository":{"id":146781696,"uuid":"206852337","full_name":"schnatterer/docker-image-size","owner":"schnatterer","description":"Queries and compares docker image sizes","archived":false,"fork":false,"pushed_at":"2020-02-15T13:05:15.000Z","size":55,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T13:30:30.798Z","etag":null,"topics":["docker","docker-image"],"latest_commit_sha":null,"homepage":"http://blog.schnatterer.info/2019/10/03/querying-docker-image-sizes-via-the-command-line","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schnatterer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-06T18:28:53.000Z","updated_at":"2024-06-03T10:40:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"3af58c5e-b898-4edf-9095-b179a3cf2cbd","html_url":"https://github.com/schnatterer/docker-image-size","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/schnatterer/docker-image-size","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schnatterer%2Fdocker-image-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schnatterer%2Fdocker-image-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schnatterer%2Fdocker-image-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schnatterer%2Fdocker-image-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schnatterer","download_url":"https://codeload.github.com/schnatterer/docker-image-size/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schnatterer%2Fdocker-image-size/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32512670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image"],"created_at":"2024-10-11T16:14:15.228Z","updated_at":"2026-05-01T21:01:24.693Z","avatar_url":"https://github.com/schnatterer.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-image-size\n\n[![Build Status](https://travis-ci.org/schnatterer/docker-image-size.svg?branch=master)](https://travis-ci.org/schnatterer/docker-image-size)\n[![](https://images.microbadger.com/badges/image/schnatterer/docker-image-size.svg)](https://hub.docker.com/r/schnatterer/docker-image-size)\n\nQueries and compares docker image sizes.  \nSee also [this blog post](http://blog.schnatterer.info/2019/10/03/querying-docker-image-sizes-via-the-command-line).\n\n\u003c!-- Update with `doctoc --notitle README.md`. See https://github.com/thlorenz/doctoc --\u003e\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [Installation](#installation)\n  - [Docker](#docker)\n  - [Local](#local)\n- [Usage](#usage)\n  - [Docker](#docker-1)\n  - [Local](#local-1)\n  - [Querying a single image](#querying-a-single-image)\n  - [Examples](#examples)\n  - [Implementations](#implementations)\n  - [Features per implementation](#features-per-implementation)\n  - [Query size with docker manifest](#query-size-with-docker-manifest)\n  - [Query size with curl](#query-size-with-curl)\n  - [Query size with reg](#query-size-with-reg)\n- [Implementation notes](#implementation-notes)\n- [Debugging](#debugging)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\n## Installation\n\n### Docker\n\nMost convenient: don't install at all; just run docker container (see [usage](#usage)).\nYou can use it even more convenient by establishing an alias\n\n```bash\nalias docker-image-sizes='docker run --rm -e DIS_IMPL schnatterer/docker-image-size'\n# If you want to query the size of a single image (faster)\n# e.g. using curl (alternatives: docker, reg)\nalias docker-image-size='docker run --rm --entrypoint docker-image-size-curl.sh schnatterer/docker-image-size'\n``` \n\nNote that the image is cached locally, if you ever want to \"update\", just do a \n\n```bash\ndocker pull schnatterer/docker-image-size\n```\n\n### Local\n* Install `jq`, e.g `sudo apt get install jq`  \n  (the script variants have additional requirements that they will tell you on startup)\n* Clone repo\n* Use either\n  * directly from repo or \n  * more convenient put it on the PATH, e.g. like so \n    ```bash\n    sudo ln -s $(pwd)/scripts/docker-image-size-docker.sh  /usr/local/bin/docker-image-size-docker.sh\n    sudo ln -s $(pwd)/scripts/docker-image-size-curl.sh  /usr/local/bin/docker-image-size-curl.sh\n    sudo ln -s $(pwd)/scripts/docker-image-size-reg.sh  /usr/local/bin/docker-image-size-reg.sh\n    sudo ln -s $(pwd)/scripts/docker-image-sizes.sh  /usr/local/bin/docker-image-sizes\n    ```\n\n## Usage\n\nNote the execution might take minutes (depending on the number of tags to query), because `docker manifest` is \ninfamously slow. You can use other [implementations](#implementations) that might be less compatible with some repos, \nthough.\n\n### Docker\n\n```bash\ndocker run --rm schnatterer/docker-image-size \u003cdocker image name\u003e [\u003cextended grep regex on docker tag\u003e]\n# Or with the alias mentioned above:\ndocker-image-sizes \u003cdocker image name\u003e [\u003cextended grep regex on docker tag\u003e]\n```\n\n### Local\n\n```bash\ndocker-image-sizes \u003cdocker image name\u003e [\u003cextended grep regex on docker tag\u003e]\n# or from repo \nscripts/docker-image-sizes.sh \u003cdocker image name\u003e \u003cextended grep regex on docker tag\u003e\n```\n\n### Querying a single image\n\nIf you care about size of one image only you can use the [implementations](#implementations) directly, which for the \n`curl` implementation responds in about a second. Note that it takes only one parameter, similar to `docker run`:\n\n```bash\n# e.g. using curl (alternatives: docker, reg)\n$ docker-image-size-curl.sh \u003cdocker image name\u003e[:\u003cTag\u003e | @\u003cRepoDigest\u003e]\n# Or using the docker image\n$ docker run --rm --entrypoint docker-image-size-curl.sh schnatterer/docker-image-size \u003cdocker image name\u003e[:\u003cTag\u003e | @\u003cRepoDigest\u003e]\n``` \n\n### Examples\n\n```bash\n# Match all tags containing '11' (a whole lot. Will take ages!)\ndocker-image-sizes adoptopenjdk 11\n# More accurate (and faster) output\ndocker-image-sizes adoptopenjdk '^11.0.4'\n# Multi arg results can be filtered using grep \ndocker-image-sizes adoptopenjdk '^11.0.4' | grep 'amd64 linux'\n# Query a single image (fastest!)\ndocker-image-size-curl.sh adoptopenjdk:11.0.4_11-jre-hotspot\n```\n\n### Implementations\n\n`docker-images-sizes.sh` can use different implementations for querying the docker manifest from the repos. See \nFeatures per implementation bellow for details.  \nBy default `docker-images-sizes.sh` uses `docker` (the `docker manifest` command), but you could switch to `curl` or \n`reg` as follows:\n\n```bash\ndocker run --rm -e DIS_IMPL=curl schnatterer/docker-image-size \u003cdocker image name\u003e [\u003cextended grep regex on docker tag\u003e]\nDIS_IMPL=curl docker-image-sizes \u003cdocker image name\u003e [\u003cextended grep regex on docker tag\u003e]\n```\n\n### Features per implementation \n\nDepending on the registry you query from, not all implementations might work.\n\nSee [unit tests](test/docker-image-size.bats) for more details.\n\n|   | curl | docker | reg |\n|---|---|---|---|\n|with/without tag | ✔️ | ✔️ | ✔️ |\n|repo digest | ✔️ | ✔️ | ✔️ |\n|platform-specific digest | ✔️ | ❌ | ❌ |\n|private repos | ❌ | ✔️ | ️✔️ |\n|multi-arch | ❌ | ✔️ | ️❌ |\n|manifest v1 | ❌ | ❌ | ❌ |\n|speed | fastest | slowest️ | ️in between️ |\n|docker hub| ✔️ | ✔️ | ✔️ |\n|gcr.io | ✔️ | ✔️ | ✔️ |\n|r.j3ss.co | ️️✔️ | ️✔️ | ✔️ |\n|quay.io | ✔️ | ✔️ | ❌️ |\n|mcr.microsoft.com | ❌ | ✔️ | ❌ |\n\n### Query size with docker manifest\n\nQueries with the experimental `docker manifest` command.\nA bit slower than the others but best compatibly for repos and most features (e.g. multi-arch). Requires `docker`.\n\n```bash\n# This repo only works with -docker.sh\n$ scripts/docker-image-size-docker.sh mcr.microsoft.com/windows/servercore:1903\nmcr.microsoft.com/windows/servercore:1903 amd64 windows 10.0.18362.356: 2217 MB\n```\n\nTested with docker 19.03.2\n\n### Query size with curl \n\nQueries with plain `curl`. Fastest, fewest requirements, but also least features (e.g. no private repos, no multi-arch).\n\n```bash\n$ scripts/docker-image-size-curl.sh gcr.io/distroless/java:11-debug\ngcr.io/distroless/java:11-debug: 73 MB\n# Does not work with reg v0.16.0\n$ scripts/docker-image-size-curl.sh quay.io/prometheus/prometheus:v2.12.0\nquay.io/prometheus/prometheus:v2.12.0: 55 MB\n```\n\nTested with \n* curl 7.64.0 (x86_64-pc-linux-gnu)\n* curl 7.66.0 (x86_64-alpine-linux-musl)\n\n### Query size with reg\n\nQueries with [genuinetools/reg](https://github.com/genuinetools/reg). A compromise in terms of speed and features but\nsupports fewest registries.\n\nRequires either reg installed or docker.\n\n```bash\n$ scripts/docker-image-size-reg.sh docker.io/debian:stretch-20190204-slim\ndocker.io/debian:stretch-20190204-slim: 23 MB\n```\n\nIf you're using reg via docker, you can update to the latest version with\n```bash\ndocker pull r.j3ss.co/reg\n```\n\nTested with reg version: v0.16.0; git hash: f180c93a.\n\n## Implementation notes\n\n* The docker repository API (OCI distribution spec) allows for querying tags from images as well as the manifest, which \n  contains the size of each image layer.\n* From these sizes, the total image size can be aggregated. See [StackOverflow answer](https://stackoverflow.com/a/54813737)  \n  for basic implementation details. These are implemented in this repo as `docker-image-size-*.sh` scripts, see \n  [scripts](scripts).\n* [genuinetools/reg](https://github.com/genuinetools/reg) (`tags` command) allows for querying docker image tags on the \n  command line.\n* [docker-images-sizes.sh](scripts/docker-image-sizes.sh) brings both of them together:  for conveniently comparing\n docker image sizes of different tags on the command line.\n* The basic logic looks like this: \n ```bash\n $ docker run r.j3ss.co/reg tags maven | grep -e '^3.6.2'  | \\\n    xargs -I{}  scripts/docker-image-size-curl.sh \"maven:{}\"\n maven:3.6.2: 320 MB\n maven:3.6.2-amazoncorretto-11: 338 MB\n #...\n ``` \n* If multiple architectures are involved for a tag, it's better to use `docker-image-size-docker.sh` in order to avoid\n errors and get more details. Unfortunately, it's much slower:\n  ```bash\n  $ docker run r.j3ss.co/reg tags adoptopenjdk | grep -e '^11.0.4'  \\\n      | xargs -I{}  scripts/docker-image-size-docker.sh \"adoptopenjdk:{}\"\n  openjdk:11.0.4-jdk amd64 linux : 311 MB\n  openjdk:11.0.4-jdk arm64 linux : 303 MB\n  openjdk:11.0.4-jdk amd64 windows 10.0.17763.737: 2353 MB\n  openjdk:11.0.4-jdk amd64 windows 10.0.17134.1006: 2536 MB\n  openjdk:11.0.4-jdk amd64 windows 10.0.14393.3204: 5919 MB\n  # ...\n  ``` \n\n## Debugging\n\n```bash\nexport DEBUG=true # Results in set -x\nscripts/docker-image-size-reg.sh docker.io/debian:stretch-20190204-slim\nunset DEBUG\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschnatterer%2Fdocker-image-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschnatterer%2Fdocker-image-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschnatterer%2Fdocker-image-size/lists"}