Docker images size

How does one get the size of a Docker image before they pull it to their machine?


The size given by the docker images command is the uncompressed size of the image installed locally, you can only get from the registry the size of the compressed images (for each architecture and if you want for each layer).

Docker Hub

Get the compressed size in bytes of an image specific tag.

# for an official image the namespace is called library
curl -s | \
    jq '.results[] | select(.name=="latest") | .full_size'

# 2796860

# here the project namespace is used
curl -s | \
    jq '.results[] | select(.name=="latest") | .full_size'

# 187647701

Get the compressed size in bytes of for an image tag for a specific architecture / os.

# selecting an architecture
curl -s | \
    jq '.results[] | select(.name=="latest") | .images[] | select (.architecture=="amd64") | .size'

# 2796860

# selecting an architecture and a specific os
curl -s | \                                                                                         
    jq '.results[] | select(.name=="latest") | .images[] | select (.architecture=="amd64" and .os=="linux") | .size'

# 2529


An alternative is to use the experimental docker manifest inspect command. The advantage is that it does not rely on Docker Hub, it works as well with other registries because it’s based on the Image Manifest specification.

# activate experimental mode

docker manifest inspect -v alpine:latest | \
    jq '.[] | select(.Descriptor.platform.architecture=="amd64") | .SchemaV2Manifest.layers[].size'

# 2796860

# need to sum if multiple layers
docker manifest inspect jupyter/base-notebook:latest | \
    jq '[.layers[].size] | add'

# 187647701


This post is a mix of two of my Stack Overflow answers

References / Further reading