How does one get the size of a Docker image before they pull it to their machine?
To view the approximate size of a running container, you can use the command docker container ls -s . Running docker image ls shows the sizes of your images. To see the size of the intermediate images that make up your image use docker image history my_image:my_tag .
Inspect the size of an imageThe docker image ls command not only lists image identifiers and names. Additionally, it shows the actual size of the entire image. If you don't have any image on your local machine, go ahead and pull an image of your choice from Docker Hub.
json file where docker stores images with their sha256 values. Find the image you are looking after and copy it's sha256 hash somewhere. Find the sha265 value you found in repositories. json then look at the date.
The docker system df command displays information regarding the amount of disk space used by the docker daemon.
When you search for a docker image on Docker hub, there will be 2 tabs- Repo Info
and Tags
. Open Tags tab and you will see the sizes of all the types of images you can pull for that image.
curl -s -H "Authorization: JWT " "https://hub.docker.com/v2/repositories/library/<image-name>/tags/?page_size=100" | jq -r '.results[] | select(.name == "<tag-name>") | .images[0].size' | numfmt --to=iec-i
For images on other registry like Microsoft Container Registry
Push the image to Docker Hub and you can get the compressed size of the image on Docker Hub website.
Use docker save
to save image to a .tar file and then compress it a .tar.gz file.
docker save my-image:latest > my-image.tar # Compress the .tar file gzip my-image.tar # Check the size of the compressed image ls -lh my-image.tar.gz
Use docker manifest inspect
to observe the manifest data, which shows you the compressed size of the image.
You need to first enable it by editing ~/.docker/config.json
file and set experimental
to enable
. Example: { "experimental": "enabled" }
. More info at official docs.
Issue docker manifest inspect -v <registry-domain>/<image-name>
and see add the size
for the layers but only for your specific architecture (e.g. amd64
).
docker manifest inspect -v <registry-domain>/<image-name> | grep size | awk -F ':' '{sum+=$NF} END {print sum}' | numfmt --to=iec-i
Noted:
alpine
linux contains arm
, amd64
and several architectures), then you'll get the total of those while in actual usage docker
only uses the relevant arch
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With