Sub topic 11
What a registry does
This chapter assumes you can build an image with a Dockerfile and know the parts of an image reference (repository, tag, digest). It also assumes you have seen that an image is made of layers plus a manifest. Here we look at the server side: what a registry stores, how it answers requests, and where it stops.
A registry is a content store with a name index
A registry is a server that stores image data and serves it over HTTP. It holds two kinds of objects:
- Blobs. These are opaque chunks of bytes. Each layer is a blob, and so is each image config. A blob is stored and addressed by its digest, such as
sha256:3f4a.... - Manifests. These are small JSON documents that list a config blob and the layer blobs that make up one image. A manifest is also addressed by its digest.
On top of that content store sits a naming layer. It maps human-readable names, mainly tags, to manifest digests. The registry does not run containers, build images, or interpret layer contents. It stores bytes and keeps the name-to-digest index.
The wire protocol is the OCI Distribution Specification. Docker Hub, GitHub Container Registry, Amazon ECR, Google Artifact Registry, Harbor, and the open-source registry:2 image all implement it. This is why one client can talk to any of them.
Registry, repository, and tag
These three words are often mixed up. They sit at different levels.
| Term | What it is | Example |
|---|---|---|
| Registry | The server and its storage | `registry.example.com` |
| Repository | A named collection of related images inside a registry | `team/myapp` |
| Tag | A mutable label in a repository that points to a manifest digest | `1.0`, `latest` |
| Digest | The immutable identifier of a manifest or blob | `sha256:...` |
A registry holds many repositories. A repository holds many tags. Several tags can point to the same manifest, and moving a tag to a different manifest is a normal operation. This is why myapp:latest can mean different content on different days, while myapp@sha256:... always means the same content.
If you leave out the registry host, Docker assumes Docker Hub (docker.io). If you leave out the tag, it assumes latest. Both defaults are applied by the client, not the registry.
How a pull works
When you run docker pull registry.example.com/team/myapp:1.0, the client does roughly this:
- Ask the registry for the manifest at
/v2/team/myapp/manifests/1.0. - If the answer is an image index (a multi-platform list), pick the entry that matches the local OS and CPU, then fetch that manifest by digest.
- Read the config and layer digests from the manifest.
- Check which of those blobs already exist locally, and download only the missing ones from
/v2/team/myapp/blobs/<digest>. - Hash each downloaded blob and compare it with the digest it was requested by.
Step 5 is why a registry does not need to be trusted for integrity. A blob that does not hash to the requested digest is rejected. The tag-to-digest mapping is a different matter. A registry can return any manifest for a tag, so tags are only as trustworthy as the registry and the people who can write to it.
How a push differs
A push runs in the opposite order, and the order matters. The client uploads the blobs first, then uploads the manifest last. The registry accepts a manifest only if the blobs it references already exist. A reader therefore never sees a manifest that points at missing layers.
The client also asks before it uploads. It sends a HEAD request for each blob, and the registry replies whether it already has it. Layers shared between images, or between versions of the same image, are uploaded once. The next chapter covers the push and pull commands themselves.
Registries can also avoid re-uploading across repositories. A client can ask the registry to mount a blob from another repository in the same registry, which links the existing blob instead of copying bytes. This usually requires permission to read the source repository.
Looking at the registry API directly
The API is plain HTTP, so you can inspect it with curl. This example assumes you have a local registry on port 5000 with myapp:1.0 pushed to it, as in the local registry chapter. It also assumes jq is installed.
# Check that the registry speaks the v2 API
curl -i http://localhost:5000/v2/
# List repositories and tags
curl -s http://localhost:5000/v2/_catalog
curl -s http://localhost:5000/v2/myapp/tags/list
# Fetch the manifest for a tag
curl -s \
-H 'Accept: application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' \
http://localhost:5000/v2/myapp/manifests/1.0 | jq .
# Get the digest the tag currently points to
curl -sI \
-H 'Accept: application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' \
http://localhost:5000/v2/myapp/manifests/1.0 | grep -i docker-content-digestThe Accept header matters. A registry may store a manifest in one format and return it in another, depending on what the client says it understands. A request with no Accept header can return an older format or an error. If the tag names an image index, add application/vnd.oci.image.index.v1+json to the header.
The _catalog endpoint is optional in the specification. Hosted registries often disable it or restrict it, so do not rely on it outside a registry you run.
Public, private, and mirrored registries
Registries differ in who can read and write. A public repository allows anonymous pulls. A private one requires a token even to read. Most hosted registries accept anonymous pulls from public repositories but may rate-limit them per IP address or per account. Docker Hub does this.
Three setups are common:
- Hosted registry. A cloud service runs it for you. You manage repositories and access policies.
- Self-hosted registry. You run
registry:2, Harbor, or similar. You manage storage, TLS, authentication, and backups. - Pull-through cache. A registry you run that fetches from an upstream registry on first request and serves its stored copy afterward. This reduces rate-limit problems and external bandwidth.
What a registry does not do
- It does not guarantee that a tag stays fixed. Anyone with write access can retag.
- It does not delete data when you delete a tag. Unreferenced blobs stay until garbage collection or a retention policy removes them (see the retention chapter).
- It does not scan or sign images unless the product adds that feature. Scanning and signing are separate services layered on top of storage.
- It does not enforce that an image is runnable. A manifest for the wrong CPU architecture is stored without complaint, and fails only when you run it.
Common errors and what they mean
| Message fragment | Likely cause |
|---|---|
| `manifest unknown` | The repository exists but that tag or digest does not. Check spelling and tag. |
| `name unknown` or `repository does not exist` | The repository path is wrong, or you have no permission to see it. Some registries use this message for both. |
| `unauthorized` or `denied` | Missing or insufficient credentials. A private repository can look the same as a missing one. |
| `server gave HTTP response to HTTPS client` | The registry serves plain HTTP. Docker allows this for `localhost` only. Other hosts need TLS or an explicit insecure-registry setting. |
| `no matching manifest for linux/arm64` | The tag is an image index with no entry for your platform. |
Exercise
You push myapp:1.1 to a repository that already contains myapp:1.0. The two images share their first three layers. Which blobs does the client upload, and in what order do the blobs and manifest go?
Show answer
The client checks each blob with a HEAD request and uploads only the ones the registry lacks, which are the new layers and the new config. The three shared layers are skipped. The manifest is uploaded last, because the registry accepts a manifest only after every blob it references exists.
Exercise
A teammate says "pulling from a registry is safe, because Docker verifies the content." What does the digest check prove, and what does it not prove?
Show answer
It proves the downloaded bytes match the digest that was requested, so a blob was not corrupted or swapped in transit. It does not prove that a tag points to the manifest you intended, since tags can be moved. Pinning by digest, or verifying a signature, closes that gap.