25.6. Hosting a Private Container Registry

A registry is where images stop being local build artifacts and become shareable, versioned, deployable objects. Debian can host one with the same container tooling this chapter has already covered: the registry image implements the OCI distribution protocol, stores content addressably under a directory you choose, and runs as a rootful Quadlet unit with TLS and authentication in front. This section deploys exactly that, then exercises the operations a registry actually needs - pushing, pulling by digest from an independent client, deleting with garbage collection, backing up, and recovering from both a bad certificate and a lost data directory.

25.6.1. OCI Distribution, Registry Names, Tags, Manifests, and Digests

The OCI distribution specification defines a small HTTP API - the same one Docker Hub and every compatible registry speak - built entirely around content-addressed storage. A repository such as handbook/web holds manifests; a manifest lists a config object and a set of layers (blobs), each named by its SHA-256 digest. A tag is a mutable pointer to a manifest; a digest reference is an immutable one. Every transfer verifies digests, which is why an image pulled by digest is bit-for-bit the image that was pushed.

Endpoint Purpose
/v2/ API base; answers with an authentication challenge when auth is enabled
/v2/_catalog list repositories
/v2/<name>/tags/list list a repository's tags
/v2/<name>/manifests/<reference> fetch or delete a manifest by tag or digest
/v2/<name>/blobs/<digest> fetch a content blob

The registry name embedded in an image reference is what makes a private registry work: registry.ctr1.lab:5000/handbook/web:1.0 means "the repository handbook/web on the registry at registry.ctr1.lab port 5000", and clients treat any host name with a port as a private registry rather than the public default. Nothing about the protocol is Docker-specific - the same registry serves Podman, skopeo, and the Docker CLI alike.

25.6.2. Deploying a Version-Pinned Registry with Persistent Storage

The registry needs four things from the host: a place to store data that survives container replacement, a TLS certificate for its name, an authentication file, and a systemd unit that runs it. The packages for the administrative side are small. On ctr1, as john:

$ sudo apt install apache2-utils jq openssl

The command prompts for confirmation. apache2-utils provides htpasswd for the credential file, jq for reading JSON API responses, and openssl for the certificate work. Lay out the storage under /srv/registry, on the host filesystem where backup and capacity policy apply. On ctr1, as root:

# install -d -m 755 /srv/registry/data /srv/registry/certs /srv/registry/auth

The command produces no output. The registry's own configuration is stored on the host and mounted into the container; create /srv/registry/config.yml with:

version: 0.1
storage:
  filesystem:
    rootdirectory: /var/lib/registry
  delete:
    enabled: true
http:
  addr: 192.168.245.10:5000
  tls:
    certificate: /certs/registry.crt
    key: /certs/registry.key
auth:
  htpasswd:
    realm: Handbook Registry
    path: /auth/htpasswd

Three settings deserve attention. rootdirectory is the container-side path; the Quadlet unit mounts /srv/registry/data there, so the data lives on the host while the registry sees its expected path. delete: enabled: true turns on the deletion endpoint that Section 25.6.5 exercises - without it the API refuses deletes, which is the correct posture for a registry you do not intend to prune. And addr binds the lab address explicitly, not every interface.

TLS first. The certificate must carry the name clients will use, so create the extension file /srv/registry/certs/ext.cnf with:

subjectAltName=DNS:registry.ctr1.lab,IP:192.168.245.10

Generate a lab certificate authority and a server certificate signed by it. On ctr1, as root, in /srv/registry/certs:

# openssl req -x509 -newkey rsa:2048 -nodes -days 3650 -keyout ca.key -out ca.crt -subj '/CN=Handbook Lab Registry CA'
# openssl req -newkey rsa:2048 -nodes -keyout registry.key -out registry.csr -subj '/CN=registry.ctr1.lab'
# openssl x509 -req -in registry.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out registry.crt -days 825 -extfile ext.cnf
Command Purpose
openssl req -x509 create a self-signed certificate; here, the lab CA
openssl req -newkey create a key pair and certificate request for the server
openssl x509 -req sign a request with the CA; -CAcreateserial starts the CA's serial file
-nodes store the private key unencrypted so a service can load it at boot
-extfile ext.cnf take the subject alternative names from the extension file
-days validity period; 825 for the server certificate, long-lived for the lab CA

Each command completes with no standard output; OpenSSL reports key generation progress on standard error and writes the key and certificate files named by -keyout and -out. A production registry would use a certificate from the private PKI of Chapter 26 or a public ACME issuer as in Chapter 23; the mechanism - clients verify the certificate against a trust anchor they already hold - is identical.

Authentication next. The registry's htpasswd backend validates accounts from one file, and bcrypt is the only password hash it accepts. On ctr1, as root:

# htpasswd -Bbn publisher 'S3cret-Labs' > /srv/registry/auth/htpasswd
Option Description
-B force bcrypt hashing, the form the registry accepts
-b take the password from the command line
-n print the entry instead of editing a file, so the shell redirect builds the file

The redirect writes the file rather than the terminal; one line holding the account name and bcrypt hash lands in /auth/htpasswd as the registry sees it. The password appears in the shell's history and process list during this command - for real credentials, take the password from a prompt or a protected file instead. Lock down the material. On ctr1, as root:

# chmod 600 /srv/registry/auth/htpasswd /srv/registry/certs/*.key
# chown -R root:root /srv/registry

Both commands are silent. The private keys and the credential file are now readable only by root, and the whole tree is root-owned; the container mounts them read-only. Finally, create the unit /etc/containers/systemd/registry.container with:

[Unit]
Description=Private OCI registry
After=network-online.target
Wants=network-online.target

[Container]
Image=docker.io/library/registry:2.8.3@sha256:46faa9a1ae6813194b53921a370f2f4f8c5e1aae228a89bceafef5847a6a3278
ContainerName=registry
Network=host
Volume=/srv/registry/data:/var/lib/registry:Z
Volume=/srv/registry/certs:/certs:ro,Z
Volume=/srv/registry/auth:/auth:ro,Z
Volume=/srv/registry/config.yml:/etc/docker/registry/config.yml:ro,Z

[Service]
Restart=always

[Install]
WantedBy=multi-user.target

This is the rootful counterpart of the user unit from Section 25.4.1, and one line is new: the Image= reference pins the registry software by both tag and digest. The tag 2.8.3 tells a human what runs; the @sha256:... suffix guarantees the exact upstream bytes regardless of what the tag points to later. Pinning the registry itself by digest is the same discipline this chapter asks of its own deployments, applied to infrastructure.

Network=host is deliberate here and worth a sentence: the registry binds 192.168.245.10:5000 itself, so it needs no published port and no firewall rules - the address in config.yml is simply reachable as-is. On hosts where another runtime's firewall rules interfere with published ports, as Section 25.8.2 demonstrates, host networking sidesteps the entire class of conflict at the cost of sharing the host's network namespace. Start it. On ctr1, as root:

# systemctl daemon-reload
# systemctl start registry.service

Both commands produce no output. The generator applies [Install] at reload time, exactly as for the user unit in Section 25.4.1, so the registry will also start at boot - the lab's reboot at the end of Section 25.9.4 verifies that chain.

The registry is now listening on 192.168.245.10:5000 with its data under /srv/registry/data. What remains is trust: clients must hold the CA before they can talk to it, which is the next section's work.

25.6.3. TLS, Client Trust, Authentication, and Repository Authorization

A client verifies the registry the same way SSH verifies a host (Chapter 20): it must already possess the trust anchor and compare what the server presents against it. For TLS, the anchor is the lab CA's certificate. Podman looks for per-registry trust in a certs.d directory named after the registry:

Location Effect
~/.config/containers/certs.d/<registry>/ca.crt trust for one user's rootless store
/etc/containers/certs.d/<registry>/ca.crt trust for every rootful client on the host

Copy /srv/registry/certs/ca.crt to each client that will pull or push - over the management network, from an administrative session, or through your configuration management - and install it as ~/.config/containers/certs.d/registry.ctr1.lab:5000/ca.crt for the user, and additionally as /etc/containers/certs.d/registry.ctr1.lab:5000/ca.crt on hosts whose rootful clients need it. On ctrclient, as john:

$ mkdir -p ~/.config/containers/certs.d/registry.ctr1.lab:5000

The directory itself produces no output; place the CA file inside it under the name ca.crt. The trust must come from a source that is already authenticated - fetching a CA over the same unverified connection it is meant to vouch for authenticates nothing. Distribution of the registry CA is a one-time action per client, and certificate renewal needs no new distribution as long as the same CA signs the replacement, which Section 25.6.7 demonstrates.

With trust in place, authenticate once per client; Podman stores the credential and reuses it. On ctr1, as john:

$ printf '%s\n' 'S3cret-Labs' | podman login --tls-verify=true -u publisher --password-stdin registry.ctr1.lab:5000
Login Succeeded!

--password-stdin keeps the password off the command line and out of the process list, unlike the htpasswd step earlier; the login succeeds, which verifies three things at once: the name resolves to the registry, the TLS chain validates against the installed CA, and the credential file accepts the account.

One authorization fact matters for planning. The htpasswd backend is realm-wide: any account in the file can read and write every repository the registry holds. That is serviceable for a single-team lab - one publisher account, as here - but it is not per-repository access control. A registry that must separate, say, a public pull-only namespace from a private push namespace needs a token-based authorization service or an authenticating proxy in front of the registry; both are standard deployments of the same image, and neither is part of this exercise. What this exercise does establish is the boundary itself: the next section shows an anonymous client and a wrong password both refused at the door.

25.6.4. Pushing Images and Pulling by Digest from Independent Clients

Registry push and pull trust flow

Figure 25.5. One image, two hosts. The publisher builds and pushes over verified TLS; the independent client authenticates and pulls the same manifest by digest. The renewal note anticipates Section 25.6.7: a new certificate from the same CA changes nothing for clients, a new CA changes everything.

The publisher's side: name the image for the registry, then upload it. On ctr1, as john:

$ podman tag localhost/handbook-web:1.0 registry.ctr1.lab:5000/handbook/web:1.0 && podman push --tls-verify=true registry.ctr1.lab:5000/handbook/web:1.0
Getting image source signatures
Copying blob sha256:7938b92a516b6b5b737d905623376f435b6a3aa5eeae857866ab358955e153b4
Copying blob sha256:08bc4e534116aa76b16015484b82eac51f9a593416feae9296c8a2d4bb7aa4a2
Copying blob sha256:5811f3fad9cf1623cab94ee20c11b31b5ed5e6989acff2f47658afb59fe9f530
Copying blob sha256:dcfce455548cbf6683034347004bf3a21f969c54fba95aa0100d66539db0721c
Copying blob sha256:eb20b49b5236a52a1b21605234563b482333f78e1289aa86a959154f44e7f8c8
Copying config sha256:fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523
Writing manifest to image destination

The && pair is one logical step - name for the registry, then upload - and podman tag itself is silent. The push uploads five blobs (the image config plus layers) and writes the manifest; every object is verified by digest as it lands. Confirm what the registry now holds, through the API itself. On ctr1, as john:

$ curl -sS --cacert ~/.config/containers/certs.d/registry.ctr1.lab:5000/ca.crt -u publisher:S3cret-Labs https://registry.ctr1.lab:5000/v2/_catalog
{"repositories":["handbook/web"]}
$ curl -sS --cacert ~/.config/containers/certs.d/registry.ctr1.lab:5000/ca.crt -u publisher:S3cret-Labs https://registry.ctr1.lab:5000/v2/handbook/web/tags/list
{"name":"handbook/web","tags":["1.0"]}

Both requests verify TLS against the installed CA and authenticate with the lab credential. For day-to-day use, omit the password after -u and curl prompts for it instead, keeping it out of the shell history. The catalog lists repositories, the tags endpoint lists the one version pushed. Now read the manifest's digest - the value a deployment should pin. On ctr1, as john:

$ skopeo inspect --tls-verify=true --creds publisher:S3cret-Labs docker://registry.ctr1.lab:5000/handbook/web:1.0 | jq -r '.Digest, .RepoTags[]'
sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
1.0
Option Description
--tls-verify verify the registry's certificate (the default; explicit here)
--creds USER[:PASS] authenticate; without a password, skopeo prompts
docker:// address a registry through the Docker/OCI protocol without storing the image

skopeo inspect reads the registry's metadata without pulling the image; the pipeline through jq extracts the digest and tags. The digest is the manifest's hash - the identity of the exact image content, independent of the tag. Record it; the deployment in Section 25.9 pins this value.

The consumer's side, on a host that has never run this application. On ctrclient, as john:

$ printf '%s\n' 'S3cret-Labs' | podman login --tls-verify=true -u publisher --password-stdin registry.ctr1.lab:5000
Login Succeeded!

Pull the manifest by digest, not by tag. On ctrclient, as john:

$ podman pull --tls-verify=true registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
Trying to pull registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e...
Getting image source signatures
Copying blob sha256:e8fd4134be5fd28ad73e449af0eadab39eb0196c86c70c688198a54c0625ff41
Copying blob sha256:c265cb3fa7c80ac67446fc0db739a202eace2b21df78d52382314a7500106fe5
Copying blob sha256:de2651157514a5b93fe82c52ae7d5d46c4af31bf8a567bd08c58c05ccac84684
Copying blob sha256:fc54165448d97c3cabb093f937a40d5ae0ee388acc90ee463f471de4e307ce37
Copying blob sha256:d5b3ea0df3ea07741683cd79c30264bbd3c899d4d269117fcfd8076731744ce5
Copying config sha256:fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523
Writing manifest to image destination
fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523

The final line is the image ID - identical to the one the build produced on ctr1 in Section 25.2.4 (fdd4551414df...), because it is the same image: same config, same layers, verified by the same digests on both sides of the transfer. Run it to prove the content arrived intact. On ctrclient, as john:

$ podman run --rm registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e cat /srv/index.html
Debian handbook web container

The digest-pinned image contains exactly the file the build copied in. Clean up the client's credentials. On ctrclient, as john:

$ podman logout registry.ctr1.lab:5000
Removed login credentials for registry.ctr1.lab:5000

The pull pipeline is now complete and repeatable: push from the builder, record the digest, and any client with the CA and an account can deploy the exact bytes. The tag remains the human interface - :1.0 is easier to read than a hash - while the digest is the machine interface that makes "which image is running" a question with one true answer.

25.6.5. Retention, Deletion, Garbage Collection, and Concurrent-Write Constraints

Registry data grows in one direction unless something deletes it. The filesystem storage driver never frees space on its own: deleting a manifest removes the reference, and a separate garbage-collection pass reclaims the blobs no manifest references. The delete: enabled: true setting from Section 25.6.2 is what makes the first half possible.

Deletion goes through the manifests endpoint, addressed by digest - deleting by tag would be ambiguous once tags move. Push a disposable copy to delete. On ctr1, as john:

$ podman tag localhost/handbook-web:1.0 registry.ctr1.lab:5000/test/disposable:1.0 && podman push --tls-verify=true registry.ctr1.lab:5000/test/disposable:1.0
Getting image source signatures
Copying blob sha256:7938b92a516b6b5b737d905623376f435b6a3aa5eeae857866ab358955e153b4
Copying blob sha256:08bc4e534116aa76b16015484b82eac51f9a593416feae9296c8a2d4bb7aa4a2
Copying blob sha256:5811f3fad9cf1623cab94ee20c11b31b5ed5e6989acff2f47658afb59fe9f530
Copying blob sha256:dcfce455548cbf6683034347004bf3a21f969c54fba95aa0100d66539db0721c
Copying blob sha256:eb20b49b5236a52a1b21605234563b482333f78e1289aa86a959154f44e7f8c8
Copying config sha256:fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523
Writing manifest to image destination

The push reports the same five digests as the original - both tags point at one set of blobs, which is the storage model in action: the disposable repository consumed no new space beyond its manifest. Read the new tag's digest with the skopeo command from Section 25.6.4; it is the same manifest digest, sha256:4c946d66.... Delete that manifest through the API. On ctr1, as john:

$ curl -sS -o /dev/null -w '%{http_code}\n' -X DELETE --cacert ~/.config/containers/certs.d/registry.ctr1.lab:5000/ca.crt -u publisher:S3cret-Labs https://registry.ctr1.lab:5000/v2/test/disposable/manifests/sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
202

The -w '%{http_code}' option prints just the response status: 202 Accepted, the registry's "deletion scheduled" answer. The tag path is gone immediately, as the next pull proves. On ctrclient, as john:

$ podman pull --tls-verify=true registry.ctr1.lab:5000/test/disposable:1.0
Trying to pull registry.ctr1.lab:5000/test/disposable:1.0...
Error: initializing source docker://registry.ctr1.lab:5000/test/disposable:1.0: reading manifest 1.0 in registry.ctr1.lab:5000/test/disposable: manifest unknown

manifest unknown is the registry's honest answer for a deleted reference. The blobs, however, are still on disk - the live handbook/web tag references them. Garbage collection is the pass that reconciles the two, and it must run against a registry that is not taking writes: the garbage collector scans the store and deletes unreferenced blobs, so a push landing mid-scan can be recorded in the manifest but lose its blobs, or vice versa. Stop the service first. On ctr1, as root:

# systemctl stop registry.service

The stop is silent. Then run the registry image's own garbage collector against the same storage and configuration the service uses. On ctr1, as root:

# podman run --rm --network=none -v /srv/registry/data:/var/lib/registry:Z -v /srv/registry/config.yml:/etc/docker/registry/config.yml:ro,Z docker.io/library/registry:2.8.3@sha256:46faa9a1ae6813194b53921a370f2f4f8c5e1aae228a89bceafef5847a6a3278 garbage-collect /etc/docker/registry/config.yml
handbook/web
handbook/web: marking manifest sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
handbook/web: marking blob sha256:fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523
handbook/web: marking blob sha256:c265cb3fa7c80ac67446fc0db739a202eace2b21df78d52382314a7500106fe5
handbook/web: marking blob sha256:de2651157514a5b93fe82c52ae7d5d46c4af31bf8a567bd08c58c05ccac84684
handbook/web: marking blob sha256:fc54165448d97c3cabb093f937a40d5ae0ee388acc90ee463f471de4e307ce37
handbook/web: marking blob sha256:d5b3ea0df3ea07741683cd79c30264bbd3c899d4d269117fcfd8076731744ce5
handbook/web: marking blob sha256:e8fd4134be5fd28ad73e449af0eadab39eb0196c86c70c688198a54c0625ff41
test/disposable

7 blobs marked, 0 blobs and 0 manifests eligible for deletion

Read the report from the bottom up: the collector walked the deleted test/disposable repository, found nothing left to mark, then marked the live manifest and its six blobs. Seven objects are in use, zero are unreferenced, so zero were deleted - correct behavior, because the deleted repository shared every blob with the live one. Had the disposable image carried its own layers, those layers would have been swept. The collector uses the same version-pinned image as the service, mounted over the same data directory, with --network=none because garbage collection needs no network at all. Restart the registry. On ctr1, as root:

# systemctl start registry.service

The command is silent and the service returns to duty. Retention policy follows from this machinery: delete manifests that outlived their tags, garbage-collect on a schedule - or on demand before the disk fills - and never while a push can land. A registry whose clients deploy by digest (Section 25.9) needs the pinned manifests kept; tag deletion is safe only when no deployment references the tag's digest.

25.6.6. Monitoring Storage, Backing Up Registry Data and Credentials, and Restoring Service

The registry's capacity is the host filesystem's capacity; the registry reports no quota of its own with the filesystem driver. Check both the store's size and its containing filesystem. On ctr1, entered by john:

$ sudo du -sh /srv/registry/data
5.3M    /srv/registry/data
$ df -h /srv/registry/data | tail -1
/dev/vda1        98G  2.2G   91G   3% /

The store is small because two tags share one image's blobs; the filesystem is the one to watch, and tail -1 keeps only its row. Put capacity monitoring on the same schedule as garbage collection - a registry that fills its filesystem refuses writes before it fails outright, and the error surfaces on clients as failed pushes.

A complete backup of this registry is one archive: the data directory, the certificates, the credential file, and the configuration. Back it up into john's workspace, which is where the chapter keeps its recovery artifacts. On ctr1, as root:

# tar -C /srv/registry -czf /home/john/debian-handbook/containers/backups/registry-full.tar.gz data certs auth config.yml

The command writes the archive and produces no terminal output; tar stays silent unless asked to be verbose. Hand the archive to john - the ownership change prints nothing - and confirm its contents. On ctr1, as root:

# chown john:john /home/john/debian-handbook/containers/backups/registry-full.tar.gz
# tar -tzf /home/john/debian-handbook/containers/backups/registry-full.tar.gz | head -5
data/
data/docker/
data/docker/registry/
data/docker/registry/v2/
data/docker/registry/v2/repositories/

tar -t lists the archive without extracting; head -5 bounds the listing, and the visible path data/docker/registry/v2/repositories/ is the content-addressed store - manifests and blobs under digest-named directories. The archive includes the CA's private key and the htpasswd file, so it must be protected like the live directory: the file-handling and encryption practices of Chapter 15 apply to it directly, and the copy stored off the host should be access-controlled the way the credential material of Chapter 26 is.

Restoration is the reverse operation, and the exercise that proves a backup is real: lose the data, then get it back. On ctr1, as root:

# systemctl stop registry.service
# mv /srv/registry/data /srv/registry/data.lost

The mv is the simulated loss - the store, with every pushed image, is now parked aside. Restore from the archive. On ctr1, as root:

# tar -C /srv/registry -xzf /home/john/debian-handbook/containers/backups/registry-full.tar.gz
# systemctl start registry.service
# systemctl is-active registry.service
active

The extraction is silent, the service restarts, and the status is active. The proof a registry actually recovered is a client pulling what it could pull before. On ctrclient, as john:

$ podman pull --tls-verify=true registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
Trying to pull registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e...
Getting image source signatures
Copying blob sha256:e8fd4134be5fd28ad73e449af0eadab39eb0196c86c70c688198a54c0625ff41
Copying blob sha256:c265cb3fa7c80ac67446fc0db739a202eace2b21df78d52382314a7500106fe5
Copying blob sha256:de2651157514a5b93fe82c52ae7d5d46c4af31bf8a567bd08c58c05ccac84684
Copying blob sha256:fc54165448d97c3cabb093f937a40d5ae0ee388acc90ee463f471de4e307ce37
Copying blob sha256:d5b3ea0df3ea07741683cd79c30264bbd3c899d4d269117fcfd8076731744ce5
Copying config sha256:fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523
Writing manifest to image destination
fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523

The same manifest, the same five blobs, the same image ID - the registry serves its images again from restored data, with no client-side change of any kind. Remove the parked loss simulation. On ctr1, as root:

# rm -rf /srv/registry/data.lost

25.6.7. Testing Denied Access, Certificate Renewal, and Recovery of Stored Images

Three failure classes deserve deliberate testing rather than hope: a client without credentials, a certificate reaching the end of its life, and trust that silently stops working. All three are safe to exercise on a lab registry, and each is one console session.

First, denial. A client that is not logged in must be refused, and so must a client with the wrong password. On ctrclient, as john, without a login (Section 25.6.4 logged out):

$ podman pull --tls-verify=true registry.ctr1.lab:5000/handbook/web:1.0
Trying to pull registry.ctr1.lab:5000/handbook/web:1.0...
Error: initializing source docker://registry.ctr1.lab:5000/handbook/web:1.0: reading manifest 1.0 in registry.ctr1.lab:5000/handbook/web: authentication required

The TLS handshake succeeded - the client trusts the registry - but the API refused the request: authentication required. Now the wrong password. On ctrclient, as john:

$ printf 'wrong-password\n' | podman login --tls-verify=true -u publisher --password-stdin registry.ctr1.lab:5000
Error: logging into "registry.ctr1.lab:5000": invalid username/password

The registry rejected the credential without disturbing the stored credentials on the client, and the failure is reported as an authentication verdict, not a network or TLS error - the distinction matters when diagnosing a client that "cannot pull": authentication required and invalid username/password are policy working, while certificate errors (below) are trust failing. Log in correctly again before the next test. On ctrclient, as john:

$ printf '%s\n' 'S3cret-Labs' | podman login --tls-verify=true -u publisher --password-stdin registry.ctr1.lab:5000
Login Succeeded!

Second, renewal. Generate a fresh server key and request, sign it with the same CA, replace the certificate, and restart. On ctr1, as root, in /srv/registry/certs:

# openssl req -newkey rsa:2048 -nodes -keyout registry.key -out registry-renew.csr -subj '/CN=registry.ctr1.lab'
# openssl x509 -req -in registry-renew.csr -CA ca.crt -CAkey ca.key -CAserial ca.srl -out registry-renew.crt -days 825 -extfile ext.cnf
# mv registry-renew.crt registry.crt

As in Section 25.6.2, the OpenSSL commands write their files and report progress on standard error only; the mv is silent. The signing uses -CAserial ca.srl to continue the CA's existing serial sequence - -CAcreateserial created that file at first issue. Restore ownership and permissions, then restart - all three steps are silent - and inspect the new certificate. On ctr1, as root:

# chown root:root registry.crt registry.key
# chmod 600 registry.key
# systemctl restart registry.service
# openssl x509 -in /srv/registry/certs/registry.crt -noout -serial -subject
serial=2B36009D640C202F610276AA7B108D8121415391
subject=CN=registry.ctr1.lab

The new serial differs from the old one; the subject and the SAN extensions are unchanged. The client needs nothing - it verifies the chain, and the CA in its trust store signed this certificate too. On ctrclient, as john:

$ podman pull --tls-verify=true registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
Trying to pull registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e...
Getting image source signatures
Copying blob sha256:e8fd4134be5fd28ad73e449af0eadab39eb0196c86c70c688198a54c0625ff41
Copying blob sha256:c265cb3fa7c80ac67446fc0db739a202eace2b21df78d52382314a7500106fe5
Copying blob sha256:de2651157514a5b93fe82c52ae7d5d46c4af31bf8a567bd08c58c05ccac84684
Copying blob sha256:fc54165448d97c3cabb093f937a40d5ae0ee388acc90ee463f471de4e307ce37
Copying blob sha256:d5b3ea0df3ea07741683cd79c30264bbd3c899d4d269117fcfd8076731744ce5
Copying config sha256:fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523
Writing manifest to image destination
fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523

Renewal from the same CA is therefore a server-side-only operation: re-sign, replace, restart. This is also the moment to apply the changed- key discipline of Chapter 20 by analogy - a renewal you did not perform, or a certificate signed by an unfamiliar issuer, is a security event, not a nuisance to click through. The third test makes that concrete.

Third, broken trust. Save the good certificate pair, then install a self-signed replacement - the kind of substitution a hijacked or misconfigured endpoint would present. On ctr1, as root, in /srv/registry/certs:

# cp registry.crt registry.good.crt
# cp registry.key registry.good.key
# openssl req -x509 -newkey rsa:2048 -nodes -days 30 -keyout registry.key -out registry.crt -subj '/CN=registry.ctr1.lab' -addext 'subjectAltName=DNS:registry.ctr1.lab,IP:192.168.245.10'

The new certificate is self-signed: same name, even the same SAN extensions, but no chain to the CA any client holds. The copies are silent and the signing again reports only on standard error. Restart the registry. On ctr1, as root:

# systemctl restart registry.service

The restart is silent. The client's verdict is the entire point of the exercise. On ctrclient, as john:

$ podman pull --tls-verify=true registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
Trying to pull registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e...
Error: initializing source docker://registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e: pinging container registry registry.ctr1.lab:5000: Get "https://registry.ctr1.lab:5000/v2/": tls: failed to verify certificate: x509: certificate signed by unknown authority

The name matched, the extensions matched, and the client refused anyway: x509: certificate signed by unknown authority. TLS verification is doing exactly its job - a client that could be talked into accepting this certificate could be talked into accepting any. The remedy is not to weaken the client but to restore the legitimate certificate. On ctr1, as root, in /srv/registry/certs:

# mv registry.good.crt registry.crt
# mv registry.good.key registry.key
# systemctl restart registry.service

The moves and the restart are all silent, and the client recovers with no change on its side. On ctrclient, as john:

$ podman pull --tls-verify=true registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e
Trying to pull registry.ctr1.lab:5000/handbook/web@sha256:4c946d6657714df40b58a082ce6a8cdfdda826030a377e191a908c8e05c1ea5e...
Getting image source signatures
Copying blob sha256:e8fd4134be5fd28ad73e449af0eadab39eb0196c86c70c688198a54c0625ff41
Copying blob sha256:c265cb3fa7c80ac67446fc0db739a202eace2b21df78d52382314a7500106fe5
Copying blob sha256:de2651157514a5b93fe82c52ae7d5d46c4af31bf8a567bd08c58c05ccac84684
Copying blob sha256:fc54165448d97c3cabb093f937a40d5ae0ee388acc90ee463f471de4e307ce37
Copying blob sha256:d5b3ea0df3ea07741683cd79c30264bbd3c899d4d269117fcfd8076731744ce5
Copying config sha256:fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523
Writing manifest to image destination
fdd4551414df382f9fb0ae62ed7fd354ac626dc04d92b17a651e69c5872b8523

Three classes, three verdicts: policy refusal for missing or wrong credentials, silent continuation for same-CA renewal, hard failure for unverifiable trust. A registry operator who has exercised all three on a lab can read a client error in production and know which of the three worlds they are in.