Skip to content

registry

The CNCF Distribution registry, the server behind docker push, as its project publishes it in the official registry image, for a dotdash relay's or server's site. Visitors and probes that open the domain find a private container registry: an empty page at /, and a password prompt at /v2/. It is the default self-hosted registry; a 2023 scan found more than 10,000 private registries reachable on the internet, of every make, which is the weakest crowd figure of these apps.

Nothing of this repository is in it but the image it holds: the registry image is upstream's, unmodified, pinned by tag and digest in bundle/manifest.yaml. Renovate proposes each new upstream release. The bundle sets the password, keeps upstream's debug server inside the container, and joins the site's network.

It used 15 MiB of memory idle and at most 31 MiB, while starting, on a test machine (limit 64 MiB). It keeps its images as files in its volume and runs on amd64 and arm64. The image is 64 MB unpacked.

The image it holds

A registry no one ever pushed to is a rare thing to find behind a password, and its volume would hold nothing for morzer's backups. So before the registry first starts, bundle/seed/seed.sh puts one image in its storage, the repository and tag image names, laid out as a push leaves it. It holds one layer, a file of 1 to 4 MiB of random bytes at /usr/local/bin/<the repository's last part>, with a config as BuildKit writes one, so its size and digests differ on every install. It shows only to someone signed in, who can pull it as any image. The seed runs once; a new image adds that one beside it.

Name it as a small team names its images: team/api:1.4.2, tools/backup:2.0.1.

What a stranger can reach

  • /: 200 with an empty body, as on every Distribution registry.
  • /v2/: 401, {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}, Www-Authenticate: Basic realm="Registry Realm" (the realm parameter) and Docker-Distribution-Api-Version: registry/2.0. A browser shows a password prompt. Every other path answers 401 or 404.
  • No version in any header or body.
  • No limit on sign-in tries, as upstream has none: a long random password and bcrypt's cost are what hold.

Upstream's own configuration serves Prometheus metrics, health and pprof on port 5001 to anything on the network, and logs at debug. Here the debug server listens on the container's loopback alone, and the log is at info.

What it calls out to

Nothing: on a test machine, it looked up no name in 12 minutes. Upstream's traces are off in its image (OTEL_TRACES_EXPORTER=none), and no proxy cache or notification is set.

Pair it with a relay

Every relay has a site, on dotdash relay 0.29 or later (0.28 needed the own-site profile): a Caddy on the Docker network dotdash-relay_edge, which serves the relay's domain. registry joins that network as registry, so the relay's cover parameter points at http://registry:5000. Caddy then passes the app every request except subscriptions, XHTTP and your own files in /srv/dotdash-relay, which take precedence over the app: keep that directory empty, or a stranger finds files no registry has.

It also runs on a server: there, set network=dotdash_edge and use --product dotdash for the server's cover.

Install

The relay goes first, dotdash relay 0.29 or later, because it creates the network the app joins. The registry takes only bcrypt lines, which htpasswd from Apache's tools makes, here from the httpd image:

sudo morzer init --release oci://ghcr.io/morzecrew/dotdash-utils/registry:stable \
  --set image=team/api:1.4.2
pw=$(openssl rand -base64 24); echo "$pw"                      # keep it to sign in
printf %s "$pw" | sudo docker run --rm -i --entrypoint htpasswd docker.io/library/httpd:2.4-alpine -niB ops \
  | sudo morzer --product registry secret set htpasswd
sudo morzer --product registry apply
sudo morzer --product registry status                         # wait for healthy

sudo morzer --product dotdash-relay config set cover=http://registry:5000

init prints the release's signing key and trusts it from then on. To check even this first release, add --signing-key with the release key this repository publishes.

morzer undoes the last config set if the site cannot reach the app, so run it only once status shows the app healthy. With two installations on the machine, every morzer command names the one it means with --product; sudo morzer shell registry opens a shell where commands mean this one.

Parameters

Parameter Default What it does
image required The image it holds from its first start, <repository>:<tag>, such as team/api:1.4.2.
realm Registry Realm What the password prompt names, in Www-Authenticate. The default is the example in upstream's configuration page, which most installs keep.
network dotdash-relay_edge The site's Docker network: dotdash-relay_edge on a relay, dotdash_edge on a server. It must exist before the app is applied.
Secret What it is
htpasswd Who may sign in: <user>:<bcrypt hash> lines, as htpasswd -nB prints them. The registry refuses to start without one.

Updating

Each upstream release reaches a relay in three steps: Renovate's pull request moves the pin (merge it once its smoke install passes), main publishes the bundle on the dev channel, and a release tag puts it on stable. Then, on each machine:

sudo morzer --product registry update      # the newest stable release
sudo morzer --product registry rollback    # back to the one before

The registry keeps no database, and every 2.x and 3.x release lays images out the same way, so a rollback works too.

To remove it, point the site back at its own page first, then remove the installation. installation list shows its id. The data volume stays unless you add --purge:

sudo morzer --product dotdash-relay config set cover=pages
sudo morzer --product registry installation remove --force --confirm <its inst_… id>