SSD Nodes Learn Hosting plans →
Guides Matt ConnorBy Matt Connor

Self-Hosted Docker Registry: Which to Run

Distribution, zot, Harbor or your forge's built-in registry? Choose by moving parts, then set up the TLS and garbage collection that most tutorials skip.

Which self-hosted Docker registry should you run?

For one small team on one VPS, choosing a self-hosted Docker registry comes down to how many moving parts you want to own. If one person or a few people push images, run CNCF Distribution (the registry image) or zot behind the reverse proxy you already have. If role-based access control (RBAC) or replication to other registries is a hard requirement, run Harbor and accept its multi-container stack. If you already run Forgejo or Gitea, use the registry built into the forge and add nothing.

Feature lists do not settle this, because all four options push and pull the same images. The difference is what you must keep running and upgrade. Every extra container can fail on its own, and each one needs its own upgrades.

ChartContainers each option adds to a VPS
The data behind this chart
[
  {
    "tool": "Distribution",
    "containers_added": 1
  },
  {
    "tool": "zot",
    "containers_added": 1
  },
  {
    "tool": "Forgejo or Gitea registry",
    "containers_added": 0
  },
  {
    "tool": "Harbor, default template",
    "containers_added": 9
  },
  {
    "tool": "Harbor, with Trivy",
    "containers_added": 10
  }
]

Distribution is 1 container. zot is 1 binary or container. The forge registry adds 0, because it runs inside the forge's own process. Harbor's default compose template on its main branch defines 9 services: log, registry, registryctl, postgresql, core, portal, jobservice, redis and an nginx proxy. Add the Trivy scanner and it becomes 10. Count them on your own install with docker compose ps, because the template changes between releases.

What each project needs in RAM at idle

The deployment and configuration docs for Distribution, zot and Forgejo give no idle memory figure. Harbor is the only one that states hardware requirements, and those are installation minimums, not measurements: 2 CPU cores minimum (4 recommended), 4 GB RAM minimum (8 GB recommended), and 40 GB disk minimum (160 GB recommended).

Do not trust a comparison table for this. Measure on your own box after a day of normal use:

sudo docker stats --no-stream

The MEM USAGE column is the number to compare. For Harbor, add up every harbor-* container plus registry, registryctl, redis and nginx. Harbor's 4 GB floor matters on a small VPS, because the same box usually also runs the apps that pull the images.

Distribution v3: what changed from registry:2

Many tutorials still use registry:2. As of 4 December 2026, the latest Distribution release is v3.1.3 (3 December). The official registry image on Docker Hub lists 3.1.3, 3.1, 3 and latest as its supported tags, and its quick start uses registry:3. Tag 2 is no longer in that list.

The v3.0.0 release changed things that break old setups:

  • The default configuration path is now /etc/distribution/config.yml. A compose file that mounts a config file at the old v2 location is not read, so the registry starts with the config baked into the image instead.
  • The oss and swift storage drivers were removed.
  • Code that imports Distribution as a library also changed: the standalone client package is gone, and the reference package moved to github.com/distribution/reference.

The point releases since then carry security fixes. v3.1.1 fixes CVE-2026-41888. Before 3.1.1, a DELETE on /v2/<name>/manifests/<tag> removed the tag even when storage.delete.enabled was false, so any client that could reach the API could delete tags on a registry you thought was protected. It is a delete-protection bypass, with a CVSS v4.0 base score of 6.3 (Medium). v3.1.2 and v3.1.3 add more fixes, including a rule in v3.1.3 that pull-through caches need an HTTPS upstream for Bearer authentication. Run the current v3 tag, not just 3.1.1, and read the releases page before each upgrade.

One more thing to know about the image. The program's own default for storage.delete.enabled is false, but the example config baked into the official image turns deletes on. Check what your container really runs:

sudo docker compose exec registry cat /etc/distribution/config.yml

Some projects package Distribution with nginx and a web interface in one compose file. Open their compose file. If the registry service uses the registry image, you are running Distribution, and everything in this guide applies to it.

This setup has one container. Distribution checks passwords itself, and nginx only terminates TLS (transport layer security) and forwards requests. The registry port is bound to 127.0.0.1, so the only way in from outside is through nginx.

You need a DNS name for the registry, here registry.example.com, and Docker Engine with the Compose plugin. If Compose is new to you, the Docker Compose basics for a VPS cover the commands used here.

Create the password file

Distribution's htpasswd auth accepts only bcrypt hashes. A line hashed any other way is ignored, so that user cannot log in. The -B flag below selects bcrypt.

sudo mkdir -p /opt/registry/auth /opt/registry/data
cd /opt/registry
sudo docker run --rm --entrypoint htpasswd httpd:2 -Bbn alice 'change-this-password' | sudo tee auth/htpasswd > /dev/null

The password now sits in your shell history. Remove that line from ~/.bash_history. Add more users by running the command again with tee -a instead of tee.

The compose file

Write /opt/registry/compose.yaml:

services:
  registry:
    image: registry:3.1.3
    restart: always
    ports:
      - "127.0.0.1:5000:5000"
    environment:
      REGISTRY_HTTP_HOST: https://registry.example.com
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
    volumes:
      - ./data:/var/lib/registry
      - ./auth:/auth:ro

REGISTRY_HTTP_HOST sets the external URL the registry uses when it generates URLs. Without it, the registry builds those URLs from each client request, which depends on the proxy passing the right headers. Setting it removes that dependency.

The 127.0.0.1: prefix matters. Docker's documentation says a port published on 127.0.0.1 can only be reached from the Docker host. It also warns that in releases older than 28.0.0, hosts on the same L2 network segment could still reach ports published to localhost. Check your version with docker version.

Start it and check that auth is on:

sudo docker compose up -d
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:5000/v2/

The curl line should print 401. That means the registry is up and refuses requests without a password. A 200 means auth is not active, so check the three REGISTRY_AUTH lines.

Real TLS through the reverse proxy

Distribution's deploy guide is direct about this: to make the registry reachable from other hosts, you must first secure it with TLS. Issue a certificate for registry.example.com first, as shown in getting a Let's Encrypt certificate for nginx with Certbot.

Then add a server block, for example /etc/nginx/sites-available/registry:

server {
    listen 443 ssl;
    server_name registry.example.com;

    ssl_certificate     /etc/letsencrypt/live/registry.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/registry.example.com/privkey.pem;

    client_max_body_size 0;
    chunked_transfer_encoding on;

    location /v2/ {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Host              $http_host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 900;
    }
}

Two lines in this block decide whether pushes work at all. Both come from Distribution's own nginx recipe:

  • client_max_body_size 0 removes nginx's limit on request size. Image layers are large, so a limit makes big pushes fail with HTTP 413.
  • chunked_transfer_encoding on is there to avoid HTTP 411 errors on layer uploads.

Host $http_host passes the host name the client asked for, which the recipe marks as required for the Docker client. The recipe also sets the 900-second proxy_read_timeout. If you want to know what each proxy_set_header line does in general, how an nginx reverse proxy config works walks through them.

Enable the site on the server:

sudo ln -s /etc/nginx/sites-available/registry /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Then test from your laptop:

docker login registry.example.com
docker pull alpine:3.21
docker tag alpine:3.21 registry.example.com/tools/alpine:3.21
docker push registry.example.com/tools/alpine:3.21
curl -u alice https://registry.example.com/v2/_catalog

docker login should print Login Succeeded. The last line should return JSON that lists tools/alpine. If you run Caddy or Traefik instead of nginx, check the same two points: no request body limit, and the original Host header passed through. Comparing nginx, Caddy and Traefik covers how each one handles certificates.

This design keeps auth in the registry. Distribution's recipe also shows the other design, where nginx does basic auth. There, one htpasswd file gives read access and a second file gives push access, and users who push must be listed in both. In that design nginx must add the Docker-Distribution-Api-Version header itself, because the request never reaches the registry until nginx has checked it. A team where everyone pushes does not need that split.

Why deleted images do not free disk space

This is the part most tutorials skip, and it is where a small VPS runs out of disk. A registry stores layers (blobs) once and points tags at them through manifests. Pushing a new image under an old tag, such as myapp:main, moves the tag. The old manifest and its layers stay on disk. Deleting a tag also leaves the layers on disk. Space comes back only when garbage collection (GC) runs.

Distribution's GC has one hard rule: the registry must be in read-only mode or not running at all. GC works in two phases. It first marks every layer that a manifest still uses, then sweeps away the rest. A push that lands between the two phases was never marked, so its layers can be swept. On one VPS the simplest safe method is to stop the container for a few minutes:

cd /opt/registry
sudo du -sh data
sudo docker compose stop registry
sudo docker compose run --rm registry garbage-collect --dry-run --delete-untagged /etc/distribution/config.yml

--dry-run prints the mark and sweep phases without removing any data. --delete-untagged also removes manifests that no tag points to. That is what clears out old builds pushed under a reused tag. Read the dry-run output before you drop the flag. A manifest that something pulls only by its digest, never by tag, is untagged and will be deleted. Then run it for real and start the registry again:

sudo docker compose run --rm registry garbage-collect --delete-untagged /etc/distribution/config.yml
sudo docker compose start registry
sudo du -sh data

docker compose run works here because the image's entrypoint passes a first argument of garbage-collect straight to the registry program. It also keeps the service's environment and volumes. run does not publish the service's ports, so nothing can push during the sweep.

If you cannot accept a few minutes of downtime, Distribution has a read-only mode instead (storage.maintenance.readonly.enabled). Set it, restart, run GC, then remove it and restart again. Pushes fail the whole time it is on. Put the steps in a script that runs weekly from a systemd timer or cron, and watch du -sh data over a few weeks to see how fast you really grow.

Disk growth has two more controls. Push to a small, fixed set of tags (:main, :prod, one version tag per release) rather than one tag per commit, so --delete-untagged has old builds to clean. And if the VPS disk is the limit, Distribution can store its data on S3-compatible storage through a storage driver, for example a self-hosted MinIO object store on a second box.

zot: one binary, with scanning and GC built in

zot calls itself an OCI-native registry (OCI is the Open Container Initiative image format). It ships as one statically built binary, under the Apache 2 license. Authentication, authorization, garbage collection and security scanning all live in that binary. As of 4 December 2026 the latest release is v2.1.23 (2 November).

Two things make zot easier to run than Distribution on a small box:

  • Its GC runs inline, so the registry does not need to go offline. The sample config in the Linux install guide sets gc to true, with a gcDelay of 1h and a gcInterval of 6h.
  • v2.1.23 added per-repository logical byte quotas, a cap on how much each repository may hold.

It also supports htpasswd basic auth and its own TLS with a certificate path and key path. Scanning uses Trivy, configured with a trivy block in the config. The web interface stays off unless you add the ui extension. The search and scrub extensions are on when their keys are missing.

The Linux install guide downloads the zot-linux-amd64 binary from GitHub releases to /usr/bin/zot, writes /etc/zot/config.json, and runs zot serve /etc/zot/config.json as a zot user under systemd. For Docker, the docs example is docker run -p 5000:5000 ghcr.io/project-zot/zot:latest. Pin a release tag in a real compose file, and check the tag names on the project's package page first. zot uses its own JSON config format, so read its configuration reference for the exact htpasswd key names before you write the file.

Choose zot over Distribution if you want scanning or GC without downtime, and still want one process.

Harbor: when you need RBAC and replication

Harbor is a full registry platform. Images live in projects, and project members get roles, including custom roles whose permissions decide what each member can do. Replication moves images in both directions between Harbor and other registries, including non-Harbor ones. It is the right answer when those features are requirements. The cost is the footprint above, plus these points:

  • Prerequisites are Docker Engine above 20.10 and Docker Compose above 2.3.
  • Trivy is not in the default install. Add it with sudo ./install.sh --with-trivy.
  • harbor.yml needs a hostname, the HTTPS port (443 by default), certificate and key paths, harbor_admin_password (used only on first start) and data_volume.
  • Harbor ships its own nginx container on ports 443 and 80. If you already run a reverse proxy, set external_url in harbor.yml. The configuration docs cover that one option and little else about placing Harbor behind another proxy, so plan time for testing.

Harbor's GC is easier than Distribution's. It runs without interrupting use, supports a schedule (hourly, daily, weekly or a custom cron expression) and has a dry run. As with every registry here, deleting images frees nothing until GC runs. Also note that Harbor's install docs list the bundled Distribution as version 2.8.3, from the v2 line.

Forgejo or Gitea: the registry you may already have

If your team already runs Forgejo or Gitea, you have a container registry. In Forgejo the package registry is on by default, and container images work with any OCI-compliant client:

docker login git.example.com
docker tag myapp:latest git.example.com/myteam/myapp:latest
docker push git.example.com/myteam/myapp:latest

Image names follow {registry}/{owner}/{image}. Users with two-factor authentication or OAuth login must use a personal access token as the password. Both forges support only case-insensitive tag names, so image:tag and image:Tag are the same tag.

Watch the disk here too. Forgejo's [packages] defaults set no limits: LIMIT_TOTAL_OWNER_SIZE and LIMIT_SIZE_CONTAINER are -1. A cleanup_packages cron job runs at midnight and deletes unreferenced package data older than 24 hours. The container registry always keeps the latest version. Set the size limits in app.ini if several people push. If the forge sits behind nginx, check its request body limit as well, because a large layer push meets the same HTTP 413 problem.

The decision rule, in one place

  • One pushing user or a small team, no scanning requirement: Distribution behind your existing reverse proxy, as set up above.
  • Same team, but you want scanning or GC without downtime in one process: zot.
  • RBAC or replication are requirements, and the VPS has at least 4 GB RAM to spare: Harbor. Scanning alone does not need Harbor.
  • A Forgejo or Gitea instance already exists: its built-in registry, with size limits set.

Whatever you pick, back up the data directory and the auth file together. Restoring layers without the htpasswd file locks everyone out. Restoring the htpasswd file without the layers gives you working logins and no images.

FAQ

Is registry:2 still supported?

The official registry image on Docker Hub lists 3.1.3, 3.1, 3 and latest as supported tags, and 2 is not in that list. Distribution v3 moved the default config path to /etc/distribution/config.yml and removed the oss and swift storage drivers, so check those two points before you switch. Run the current v3 tag, because v3.1.1 fixed CVE-2026-41888, a bypass of storage.delete.enabled: false, and later releases added more security fixes.

Why does docker push fail with HTTP 413 through nginx?

nginx limits the size of a request body, and image layers are larger than that limit. Set client_max_body_size 0; in the registry's server block, as Distribution's nginx recipe says, then reload nginx. Also set chunked_transfer_encoding on;, which the recipe adds to avoid HTTP 411 errors.

I deleted images, so why is the disk still full?

Deleting a tag or an image only removes references. The layers stay on disk until garbage collection runs. For Distribution, stop the registry or put it in read-only mode, run garbage-collect --dry-run against /etc/distribution/config.yml, then run it again without --dry-run. zot and Harbor run GC without downtime, and Forgejo cleans unreferenced package data with a nightly cron job.

Do I need Harbor to scan images for vulnerabilities?

No. zot has Trivy scanning in its single binary, configured with a trivy block. Harbor also scans with Trivy, but its default install leaves Trivy out, so you add it with ./install.sh --with-trivy. Choose Harbor for scanning only if you also want its project roles or replication.

Was this article useful?

#docker#container-registry#self-hosting#harbor#zot#nginx