↓Skip to main content
  1. Docker Tutorials/

What Are Docker Image Registries and How Do They Work?

·5 mins

A Docker image registry is a server that stores and serves container images. Docker Hub, GitHub Container Registry, Amazon ECR, Google Artifact Registry, or self-hosted solutions like Distribution or open source git providers like forgejo are all registries — they implement the same OCI Distribution Specification, which is why docker pull works identically against all of them.

Registry, repository, and image — the terminology #

These three terms get used interchangeably, but they aren’t the same thing:

  • A registry is the server (registry.hub.docker.com, ghcr.io, 123456789.dkr.ecr.eu-central-1.amazonaws.com).
  • A repository is a named collection of images inside a registry (library/nginx, acme/api).
  • An image is a specific set of layers, usually referenced by a tag (nginx:1.27) or a content digest (nginx@sha256:...).

A fully qualified image reference is a combination of these, and looks like this: <registry>/<repository>:<tag>. If you omit the registry, Docker assumes docker.io; if you omit the tag, Docker assumes :latest.

What’s actually stored #

Registries don’t store images as single files. They store two kinds of content, both addressed by SHA-256 digests:

  • Blobs — the compressed filesystem layers and the image config JSON.
  • Manifests — a JSON document listing which blobs make up an image, plus a media type and (for multi-arch images) a manifest list pointing at per-platform manifests.

Because everything is content-addressed, a layer shared by two images only needs to be stored once. This is also why layer caching works across unrelated images: if your base image is debian:bookworm-slim, the registry (and your local Docker daemon) already has those layers the moment you pull anything else built on the same base.

What happens on docker pull #

When pulling a Docker image like library/nginx (or if you use docker run), this is what happens:

  1. Docker resolves the registry host and repository from the reference.
  2. It authenticates if required (docker login stores a token or credential helper reference in ~/.docker/config.json).
  3. It requests the manifest for the given tag via GET /v2/<repository>/manifests/<tag>.
  4. If the manifest is a manifest list (multi-arch), Docker picks the entry matching your platform and fetches that manifest.
  5. For each layer digest in the manifest, Docker checks whether it already has that blob locally. If not, it downloads it via GET /v2/<repository>/blobs/<digest>.
  6. Docker verifies each blob against its digest, then unpacks the layers to build the image.

docker push is the same process in reverse: blobs are uploaded first (registries typically deduplicate: if a blob with that digest already exists, it’s skipped), and the manifest is written last, since a manifest referencing missing blobs would be invalid.

Running your own registry #

The current reference implementation is distribution/distribution. It was previously simply called registry up until version 2, but was renamed to distribution starting with version 3. You can have one running in a minute (in this example registry:3 and distribution/distribution refer to the same image, which they are):

docker run -d -p 5000:5000 --restart=always --name registry registry:3
#> f2473c44ab1544bf0071e3f173799abddf8e9604f3ade0a81cc502bd23190cd2

docker pull alpine:latest
#> latest: Pulling from library/alpine
#> e2de96513ba9: Already exists
#> Digest: sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
#> Status: Downloaded newer image for alpine:latest
#> docker.io/library/alpine:latest

docker tag alpine:latest localhost:5000/alpine:latest
#> no output on success

docker push localhost:5000/alpine:latest
#> The push refers to repository [localhost:5000/alpine]
#> 74d97c428c51: Pushed
#> latest: digest: sha256:7cefa58bd70cbf86bb0ef44b9c27a9c6a633763977ea40868d1bfe9278967b25 size: 527

docker pull localhost:5000/alpine:latest
#> latest: Pulling from alpine
#> Digest: sha256:7cefa58bd70cbf86bb0ef44b9c27a9c6a633763977ea40868d1bfe9278967b25
#> Status: Image is up to date for localhost:5000/alpine:latest
#> localhost:5000/alpine:latest

(This round-trips a stock alpine image just to prove the registry works end to end. To push an image you’ve actually built yourself instead, see How Do You Build a Docker Image From a Dockerfile. The docker tag/docker push steps work the same either way.)

The example above works over plain HTTP with zero daemon configuration because Docker automatically treats localhost/127.0.0.0/8 as an insecure-allowed registry — that exception exists specifically so local testing like this just works. It stops applying the moment the registry is reached at anything else: a LAN IP, a real hostname, another machine’s daemon pushing to yours. From there, Docker refuses the connection outright unless you either put TLS in front of it (the real fix) or explicitly add the registry to insecure-registries in daemon.json (which works fine, but poses security issues even for a trusted internal network). For anything beyond local testing, it’s also probably better to back the storage driver with S3, GCS or Azure Blob rather than a local filesystem.

Cleaning up old images #

As mentioned before: blobs are shared, so deleting a tag doesn’t automatically reclaim disk space. The underlying blobs might still be referenced by another tag. Deletion is a two-step process: first you unlink the manifest, then you run garbage collection to sweep unreferenced blobs. On the reference registry that we spun up in the example above:

# 1. Delete the manifest by digest (not by tag — the delete API works on digests)
# You can find the digest in the output of the docker push command (see above example)
curl -X DELETE http://localhost:5000/v2/alpine/manifests/sha256:7cefa58bd70cbf86bb0ef44b9c27a9c6a633763977ea40868d1bfe9278967b25

# 2. Reclaim the space
# this command calls the /bin/registry binary on our local test-registry
docker exec registry bin/registry garbage-collect /etc/distribution/config.yml
#> time="2026-09-29T20:43:20.587532306Z" level=debug msg="using \"text\" logging formatter"
#> alpine

#> 0 blobs marked, 3 blobs and 0 manifests eligible for deletion
#> blob eligible for deletion: sha256:e2de96513ba9eb53b431787ec8a65cdde380ac4772a3e4c4b714dcfde2a102b5
#> time="2026-09-29T20:43:20.589164059Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/e2/e2de96513ba9eb53b431787ec8a65cdde380ac4772a3e4c4b714dcfde2a102b5" environment=development go.version=go1.26.8 instance.id=01a0eee8-5c8b-792d-8d7f-a203505f8b2d service=registry
#> blob eligible for deletion: sha256:320994c3b997e2ec6433f717f153e108023c5bec8fefa8d76b83451d16d05ea8
#> time="2026-09-29T20:43:20.589642689Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/32/320994c3b997e2ec6433f717f153e108023c5bec8fefa8d76b83451d16d05ea8" environment=development go.version=go1.26.8 instance.id=01a0eee8-5c8b-792d-8d7f-a203505f8b2d service=registry
#> blob eligible for deletion: sha256:7cefa58bd70cbf86bb0ef44b9c27a9c6a633763977ea40868d1bfe9278967b25
#> time="2026-09-29T20:43:20.589810264Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/7c/7cefa58bd70cbf86bb0ef44b9c27a9c6a633763977ea40868d1bfe9278967b25" environment=development go.version=go1.26.8 instance.id=01a0eee8-5c8b-792d-8d7f-a203505f8b2d service=registry
#> alpine: layer link eligible for deletion: sha256:320994c3b997e2ec6433f717f153e108023c5bec8fefa8d76b83451d16d05ea8
#> alpine: layer link eligible for deletion: sha256:e2de96513ba9eb53b431787ec8a65cdde380ac4772a3e4c4b714dcfde2a102b5
#> time="2026-09-29T20:43:20.589990853Z" level=info msg="Deleting layer link path: /docker/registry/v2/repositories/alpine/_layers/sha256/320994c3b997e2ec6433f717f153e108023c5bec8fefa8d76b83451d16d05ea8/link" environment=development go.version=go1.26.8 instance.id=01a0eee8-5c8b-792d-8d7f-a203505f8b2d service=registry
#> time="2026-09-29T20:43:20.590100246Z" level=info msg="Deleting layer link path: /docker/registry/v2/repositories/alpine/_layers/sha256/e2de96513ba9eb53b431787ec8a65cdde380ac4772a3e4c4b714dcfde2a102b5/link" environment=development go.version=go1.26.8 instance.id=01a0eee8-5c8b-792d-8d7f-a203505f8b2d service=registry

Hosted registries like Docker Hub, ECR, GHCR, etc. handle garbage collection for you, usually with a retention policy you configure rather than a manual sweep. On a self-hosted registry it might be worth setting up a cronjob before your hosting bill explodes.