DockerSelf-Hosting

Docker Registry with Docker: Your Own Private Images (Linux, Windows, Mac)

Before you start

  • 17 min read

Boxes marked Run in terminal are what you type; plain text explains why. Check what you need first

What you get in one minute#

CNCF Distribution, commonly called Docker Registry, stores your container images on your own server so you can push a build once and pull it onto your other machines.

CNCF Distribution official logo

Logo: CNCF Distribution project (https://raw.githubusercontent.com/distribution/distribution/3d4d9e0a11a4a09a2f470c4e1b1daa5c3948331f/distribution-logo.svg), Apache-2.0.

We add passwords, HTTPS and a separate browser interface. This suits private homelab builds, deployment images and keeping selected images close to your servers.

At a glance:

  • Docker clients push and pull; the registry stores manifests and layers.
  • Your data stays in a host folder that you can back up.
  • Distribution has no built-in web UI; we add Joxit Docker Registry UI.
  • Choose Harbor when you need project permissions, integrated scanning, replication and auditing. Choose Distribution for a smaller, shared-trust registry. Harbor's feature list explains that difference.
WhatValue (official sources read 3 December 2026)
Current stable versionv3.1.2, released 24 September 2026 (release)
Official imageregistry:3.1.2; the current major line is 3, not 2 (tag definition)
LicenceApache-2.0 (licence at the tag)
Time neededAbout 45 minutes with a working proxy; our estimate
RAM / image sizeNot measured in this guide; no benchmark claimed
PortsRegistry 5000 and UI 80 inside Docker; HTTPS proxy publishes 80/443
Official docsDistribution documentation

How it fits together#

Clients reach the HTTPS proxy, which sends /v2/ requests to the password-protected registry and browser requests to the UI.

Linux, Windows and Mac clients connect through HTTPS to Traefik or Caddy; API requests reach Distribution and its password file and image storage, while browser requests reach the optional web UI

Our diagram, drawn from the official configuration and API documentation.

A tag names a version; a digest identifies exact content. Several tags can refer to one manifest, and several manifests can share layers. Distribution 3 still uses the Registry HTTP API V2, including /v2/ URLs.

Before you start#

Every deployment domain, user name, password and secret below is a dummy value - replace with your own. For example, registry.example.com, change-me and ${REGISTRY_DOMAIN} are placeholders, never details from a machine or account. Official source links and Docker Hub's upstream service URL identify the real public projects/services.

SystemRequirements
LinuxA supported Linux distribution, Docker Engine and Compose plugin; amd64 or arm64 CPU is a practical choice
WindowsA Windows version supported by Docker Desktop, WSL 2 backend, Linux containers and PowerShell
MacA macOS version supported by Docker Desktop; Intel or Apple Silicon; Terminal

No GPU is needed. Reserve disk space for images, temporary uploads and a complete backup. RAM needs depend on concurrent clients; the registry does not publish a universal minimum in the sources we checked. Desktop must remain running and the computer awake.

Run these in all three terminals:

Run in terminalbash
docker --version
docker compose version
  • [ ] Both commands print versions and Docker is running.
  • [ ] Existing configuration and data are backed up before changes.
  • [ ] Ports 80/443 are free for Caddy, or already owned by your working Traefik.
  • [ ] For public HTTPS: your domain's DNS points to the server and certificate validation can reach ports 80/443.
  • [ ] For Traefik: its Docker provider, https entrypoint, le resolver and proxy network exist.
  • [ ] For home-only HTTPS: local DNS and a plan to trust Caddy's CA on each client.

Tested on 2026-12-03: Linux = not run; Windows = not run; Mac = not run. We checked documentation and source, not a live deployment. All checks below describe expected results, not captured test output.

Step 1: Create folders and a password file#

Work under ~/docker_volumes/docker-registry. The helper image supplies Apache's htpasswd; -B selects bcrypt and -c creates the file. Enter a unique password interactively, so it does not appear in command history.

Linux#

Run in terminalbash
mkdir -p ~/docker_volumes/docker-registry/{data,config,logs,backups}
cd ~/docker_volumes/docker-registry
cat > .env << 'EOF'
REGISTRY_DOMAIN=registry.example.com
REGISTRY_HTTP_SECRET=change-me
EOF
chmod 600 .env
docker run --rm -it --mount "type=bind,src=$PWD/config,dst=/auth" --entrypoint htpasswd httpd:2.4.71-alpine -Bc /auth/htpasswd change-me

Windows (PowerShell)#

Codepowershell
$base = "$HOME\docker_volumes\docker-registry"
foreach ($d in "data","config","logs","backups") {
  New-Item -ItemType Directory -Force "$base\$d" | Out-Null
}
Set-Location $base
@'
REGISTRY_DOMAIN=registry.example.com
REGISTRY_HTTP_SECRET=change-me
'@ | Set-Content -Encoding ascii .env
docker run --rm -it --mount "type=bind,src=$base\config,dst=/auth" --entrypoint htpasswd httpd:2.4.71-alpine -Bc /auth/htpasswd change-me

Mac (Terminal)#

Same commands as Linux.

Replace the dummy domain and HTTP secret in .env; use a long random secret from your password manager. The HTTP secret signs upload state; it is separate from the login password. Replace the dummy username in the helper command too. Use your editor to save .env without publishing it.

Check it worked. config/htpasswd exists and contains a username plus a bcrypt hash. Do not paste its contents into support posts. Missing bind folders or denied Desktop file sharing must be fixed before continuing.

Tip: Omit -c when adding another user, or you overwrite existing accounts. Restart the registry after changing the file: it loads passwords at startup. Only bcrypt hashes are supported.

Step 2: Write the registry and Compose configuration#

Save this as config/config.yml. Its version: 0.1 is the registry configuration schema, not the obsolete Compose version field.

File contentyaml
version: 0.1
log:
  level: info
storage:
  filesystem:
    rootdirectory: /var/lib/registry
  delete:
    enabled: true
  cache:
    blobdescriptor: ""
auth:
  htpasswd:
    realm: Private Registry
    path: /auth/htpasswd
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]

Save this as compose.yaml in the project folder:

File contentyaml
name: docker-registry
services:
  registry:
    image: registry:3.1.2
    container_name: docker-registry
    restart: unless-stopped
    environment:
      REGISTRY_HTTP_HOST: https://${REGISTRY_DOMAIN}
      REGISTRY_HTTP_SECRET: ${REGISTRY_HTTP_SECRET}
      OTEL_TRACES_EXPORTER: none
    volumes:
      - ./data/registry:/var/lib/registry
      - ./config/config.yml:/etc/distribution/config.yml:ro
      - ./config/htpasswd:/auth/htpasswd:ro
  registry-ui:
    image: joxit/docker-registry-ui:2.6.0
    restart: unless-stopped
    environment:
      SINGLE_REGISTRY: "true"
      REGISTRY_TITLE: Private Registry
      REGISTRY_URL: https://${REGISTRY_DOMAIN}
      REGISTRY_SECURED: "true"
      DELETE_IMAGES: "false"

The UI is a separate community project, not part of the Docker Official Image. We pin its 2.6.0 release, dated 19 January 2026. Both services will share one HTTPS hostname, avoiding browser cross-origin authentication problems. The UI shell is public; registry content requires authentication.

There are no published backend ports. Deletion is enabled in the API, but the UI initially hides its delete control. An empty descriptor cache follows the workaround in issue 5010; it does not disable image storage.

Linux#

Use a text editor to save the two files above, then:

Run in terminalbash
cd ~/docker_volumes/docker-registry
docker compose config -q

Windows (PowerShell)#

Use Notepad or your editor; save as config.yml and compose.yaml, not .txt files. Then:

Codepowershell
Set-Location "$HOME\docker_volumes\docker-registry"
docker compose config -q

Mac (Terminal)#

Same commands as Linux. Use a plain-text editor, not rich-text mode.

Check it worked. Compose's expected successful result is exit status zero with no output. This checks Compose syntax; it does not validate registry settings or prove HTTPS works. Select a proxy below before starting.

Put it behind HTTPS with Traefik#

With Traefik#

For a server with a domain, use the existing setup from our Traefik guide. Home-only readers can skip this route and use Caddy's internal certificates below. Labels reference existing static settings; they do not create a resolver or entrypoint.

Run docker network inspect proxy; only if absent, run docker network create proxy. These commands work on Linux, PowerShell and Mac.

Merge this into the registry service:

File contentyaml
    networks: [default, proxy]
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.registry.rule=Host(`${REGISTRY_DOMAIN}`) && PathPrefix(`/v2/`)"
      - "traefik.http.routers.registry.priority=100"
      - "traefik.http.routers.registry.entrypoints=https"
      - "traefik.http.routers.registry.tls=true"
      - "traefik.http.routers.registry.tls.certresolver=le"
      - "traefik.http.services.registry.loadbalancer.server.port=5000"

Merge this into registry-ui:

File contentyaml
    networks: [default, proxy]
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.registry-ui.rule=Host(`${REGISTRY_DOMAIN}`)"
      - "traefik.http.routers.registry-ui.priority=10"
      - "traefik.http.routers.registry-ui.entrypoints=https"
      - "traefik.http.routers.registry-ui.tls=true"
      - "traefik.http.routers.registry-ui.tls.certresolver=le"
      - "traefik.http.services.registry-ui.loadbalancer.server.port=80"

Add at the top level:

File contentyaml
networks:
  default: {}
  proxy:
    external: true

Run docker compose config -q, then docker compose up -d if validation succeeds. Higher priority sends API requests directly to Distribution; the UI catches the other paths. Save labels in the YAML file: PowerShell interprets backticks when typed inside double-quoted shell strings.

Without Traefik: Caddy#

Use this route instead of the Traefik additions. Our Caddy guide explains its certificate storage. Add this service under services:; keep both existing services on Compose's default network:

File contentyaml
  caddy:
    image: caddy:2.11.9-alpine
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./config/caddy:/etc/caddy:ro
      - ./data/caddy:/data
      - ./data/caddy-config:/config

Create config/caddy and save config/caddy/Caddyfile below. Replace the dummy hostname with the same domain used in .env; Caddy does not read that file here.

File contenttext
registry.example.com {
    handle /v2/* {
        reverse_proxy registry:5000
    }
    handle {
        reverse_proxy registry-ui:80
    }
}

On Linux/Mac use mkdir -p config/caddy; on PowerShell use New-Item -ItemType Directory -Force config/caddy. Run docker compose config -q, then docker compose up -d. Caddy obtains and renews public certificates automatically, including through Let's Encrypt, when DNS and validation reachability are correct. No backend host port is needed: registry is Docker service discovery, whereas localhost inside Caddy would mean Caddy itself.

For home-only HTTPS, add tls internal immediately inside the site block and resolve your chosen name through local DNS. Keep ports on the LAN. Once Caddy starts, export only its public root certificate:

Run in terminalbash
docker compose cp caddy:/data/caddy/pki/authorities/local/root.crt config/caddy-root.crt

This command also works in PowerShell. Transfer that certificate securely to each client; never copy the CA private key. Trust it as follows:

  • Linux Engine: copy it to /etc/docker/certs.d/registry.example.com/ca.crt. For Debian/Ubuntu system tools, also install it under /usr/local/share/ca-certificates/ and run sudo update-ca-certificates. Other distributions have their own trust-store command.
  • Windows: import it with mmc.exe into Certificates (Local Computer) → Trusted Root Certification Authorities. Restart Docker Desktop.
  • Mac: import it into Keychain Access → System, open its Trust settings and select Always Trust. Restart Docker Desktop.

Only trust the certificate from your own Caddy instance. Check curl -I https://registry.example.com/v2/ (PowerShell: curl.exe -I ...). Expected: an authentication challenge, not a certificate warning. These routes require no insecure-registries setting.

Tip: A browser trusting a certificate does not prove the Docker daemon trusts it. Configure the machine running Docker, including a remote Engine if your CLI uses one.

Security and testing#

On Linux/Mac, restrict .env with chmod 600 .env; protect the hash file with sudo chmod 600 config/htpasswd. On Windows, use folder Security permissions to limit access to your account and the identities Docker Desktop needs. Keep secrets and backups out of Git. Do not add a Docker socket mount to this registry.

Htpasswd grants shared registry access, not per-project roles. With deletion enabled, authenticated users can delete through the API even when the UI button is hidden. Keep credentials among trusted operators; use Harbor for finer permissions. Use Trivy separately to scan images.

Run these on Linux/Mac:

Run in terminalbash
curl -I https://registry.example.com/v2/
curl -i -u change-me https://registry.example.com/v2/
docker compose ps
docker logs docker-registry --tail 100
docker inspect docker-registry --format '{{json .Mounts}}'

PowerShell uses curl.exe for the two curl commands; the Docker commands are identical. Curl prompts for the password. The API documents an unauthenticated 401 challenge and authenticated 200 response. Neither is evidence from our machine. Confirm the data/config mounts and open the HTTPS root in a browser to check UI login and repository listing.

Step 3: Push and pull an image#

We reuse the pinned registry image as a harmless sample artifact. This stores an image; it does not run another server.

Linux#

Run in terminalbash
docker login registry.example.com --username change-me
docker pull registry:3.1.2
docker tag registry:3.1.2 registry.example.com/lab/registry:3.1.2
docker push registry.example.com/lab/registry:3.1.2
docker image rm registry.example.com/lab/registry:3.1.2
docker pull registry.example.com/lab/registry:3.1.2

Windows (PowerShell)#

Run in terminalpowershell
docker login registry.example.com --username change-me
docker pull registry:3.1.2
docker tag registry:3.1.2 registry.example.com/lab/registry:3.1.2
docker push registry.example.com/lab/registry:3.1.2
docker image rm registry.example.com/lab/registry:3.1.2
docker pull registry.example.com/lab/registry:3.1.2

Mac (Terminal)#

Same commands as Linux.

Check it worked. Expected: login succeeds, push reports a digest, pull succeeds and lab/registry appears in the UI. Repeat the pull on a fresh client of the same architecture to check layer transfer; removing a tag locally can leave layers cached. This workflow is not a guarantee of copying every platform in an image index. For that, see Skopeo.

Tip: Image names contain the hostname, repository and tag, without https:// or /v2/. Log in to exactly the hostname used in the image reference.

Delete images and reclaim space safely#

After taking the backup below, change the UI's DELETE_IMAGES to "true" and run docker compose up -d registry-ui. Delete only the disposable sample. The UI uses manifest deletion: other tags pointing to that same digest can disappear too. To hide deletion again, restore "false" and recreate the UI.

Deleting references does not immediately recover disk space. Garbage collection removes unreferenced blobs; layers still used by another manifest remain. Never remove storage directories by hand.

Take a fresh backup after deletion. The backup script below restarts the project when finished, so stop the registry again before collection. With every instance using this storage stopped, run these lines individually on Linux, PowerShell or Mac, continuing only on success:

Run in terminalbash
docker compose stop registry
docker compose ps -a registry
docker compose run --rm --no-deps registry garbage-collect --dry-run /etc/distribution/config.yml

Review the proposed deletions and keep the registry stopped. Only after the dry-run succeeds and the backup is confirmed, run:

Run in terminalbash
docker compose run --rm --no-deps registry garbage-collect /etc/distribution/config.yml
docker compose up -d registry

Run the second command only after collection succeeds; investigate a failure before reopening writes. Re-pull an image you retained. We omit --delete-untagged: it broadens deletion, and historical multi-platform bugs make blindly copied cleanup commands particularly risky. Official GC guidance requires stopping writes or restarting in read-only mode.

Optional: a Docker Hub pull-through cache#

Use a second project, storage folder and HTTPS hostname, such as the dummy mirror.example.com. Repeat the setup with a distinct Compose project name, container name and Traefik router/service names; omit its UI. Route all /v2/ requests to that second registry. Never point two configurations at the private registry's data.

In the second registry's configuration, retain authentication, filesystem storage, deletion and the empty descriptor cache, then add:

File contentyaml
proxy:
  remoteurl: https://registry-1.docker.io
  ttl: 168h

The upstream URL is Docker Hub's public service endpoint, not a deployment placeholder. Set the second project's REGISTRY_DOMAIN to your mirror's domain. No Hub credentials are needed for public images. Adding upstream credentials can expose every private Hub repository those credentials can read to mirror users.

For this authenticated example, use explicit pulls on all three systems:

Run in terminalbash
docker login mirror.example.com --username change-me
docker pull mirror.example.com/library/registry:3.1.2

The library/ namespace matters for Docker Official Images. We do not configure transparent registry-mirrors here: authenticated mirror behavior has client limitations, and must be checked separately. A proxy-mode registry cannot accept your pushes. Caching saves repeat downloads but still checks upstream tags; it is not an offline archive or an exemption from Hub limits. See the official mirror recipe.

Common mistakes#

These are exact error fragments from issues we opened; historical reports illustrate symptoms, not proof of a current regression. The AI row is our warning about copied advice, not a claim that the reporter used AI.

MistakeWhy it happensDo this instead
Connect to plain HTTP: http: server gave HTTP response to HTTPS client (1929)Docker expects HTTPS.Finish the proxy/certificate setup and use its HTTPS hostname.
Treat successful login as a push test: unauthorized: authentication required (1343)Upload requests can follow a different host or lose authentication.Check login target, external REGISTRY_HTTP_HOST and proxy headers; then actually push.
Trust only the browser: x509: certificate signed by unknown authority (1731)The Engine does not trust that CA.Install the correct root on the Docker client host; keep TLS verification enabled.
Break upload routing: blob upload unknown (2225)Upload paths, state or forwarded scheme/host can be inconsistent.Preserve /v2/, inspect redirects and use one persistent HTTP secret. The symptom alone does not identify the cause.
AI assistants copy aggressive v2 cleanup: manifest unknown: manifest unknown (3178)Old --delete-untagged examples can remove child manifests referenced by an index.Use current v3, stop writes, back up and review a dry-run; do not add that flag casually.
Put authenticated UI/API on separate origins: HTTP/1.1 401 Unauthorized (4458)Browser preflight is challenged before the real request.Keep UI and API on the same HTTPS origin as above.

Troubleshooting#

ProblemSolution
Registry restarts repeatedlyRun docker logs docker-registry --tail 100; check config/config.yml, bcrypt file and bind permissions.
UI loads but API returns HTMLCheck the /v2/ router priority or Caddy handle; curl -i -u change-me https://registry.example.com/v2/ should reach Distribution.
Password change has no effectRun docker compose restart registry after editing htpasswd.
Space remains after deletionInspect a stopped-registry GC dry-run; referenced shared layers are retained.
Unexpected data pathRun docker inspect docker-registry --format '{{json .Mounts}}' and verify the host source.

http: server gave HTTP response to HTTPS client#

Check the port and proxy route first. Sending Docker directly to internal HTTP port 5000 bypasses TLS. Adding an insecure-registry exception hides that design error rather than completing HTTPS.

unauthorized: authentication required#

One unauthenticated challenge is normal. Repeated failure with credentials is not. Check the username, bcrypt hash, file mount and external hostname; avoid posting authorization headers in logs.

x509: certificate signed by unknown authority#

Install Caddy's root on each client and restart Desktop. Verify the certificate matches the DNS name you use. A trusted CA does not fix a hostname mismatch.

Known bugs#

Issue 5010, opened October 2026 and still open when checked, reports zero-byte pulls with Distribution 3.1.2 in a busy pull-through cache using an in-memory descriptor cache. Its reported workaround is an empty blobdescriptor; we use that explicitly. We have not reproduced it or established that every GC/cache issue is fixed. Historical issue 3178 is not evidence that all v3 multi-platform pulls are broken.

Issue 5086 also reports GC failing on cached BuildKit content in 3.1.2. If a cache dry-run fails, preserve the data and investigate; do not create or delete internal storage directories to silence it. The private-registry recipe is our primary path; the cache remains optional.

Updates and backups#

Read release notes, stop writes and back up before changing the pinned tag. Then run these commands separately, continuing only on success:

Run in terminalbash
docker compose pull
docker compose up -d

They also work in PowerShell. Check login, an existing pull, a new push and a fresh-client pull. Diun can notify you about updates. Migrating from v2 needs extra care: v3's default config path is /etc/distribution/config.yml; test the migration on copied data and keep the old snapshot for rollback.

Our backup scripts stop the project and archive data, configuration and secrets. They are an operational example, not a registry backup feature, and have not been executed here. Keep enough space and copy archives off-host. For an existing Traefik, back up its configuration/ACME storage separately.

Linux and Mac: save as config/backup.sh, then run sh config/backup.sh from the project folder:

File contentbash
#!/bin/sh
set -eu
cd "$HOME/docker_volumes/docker-registry"
stamp=$(date +%Y%m%d-%H%M%S)
docker compose stop
trap 'docker compose start' EXIT
docker run --rm --entrypoint sh \
  --mount "type=bind,src=$PWD,dst=/source,readonly" \
  --mount "type=bind,src=$PWD/backups,dst=/backup" \
  registry:3.1.2 -c "tar czf /backup/registry-$stamp.tgz -C /source data config .env compose.yaml"

Windows (PowerShell): save as config/backup.ps1, then run ./config/backup.ps1:

Codepowershell
$ErrorActionPreference = "Stop"
$base = "$HOME\docker_volumes\docker-registry"
Set-Location $base
$stamp = Get-Date -Format "yyyyMMdd-HHmmss"
docker compose stop
if ($LASTEXITCODE -ne 0) { throw "Could not stop registry project" }
try {
  docker run --rm --entrypoint sh --mount "type=bind,src=$base,dst=/source,readonly" --mount "type=bind,src=$base\backups,dst=/backup" registry:3.1.2 -c "tar czf /backup/registry-$stamp.tgz -C /source data config .env compose.yaml"
  if ($LASTEXITCODE -ne 0) { throw "Backup failed" }
} finally {
  docker compose start
}

Schedule Linux/Mac at 03:00 with crontab -e:

File contenttext
0 3 * * * /bin/sh "$HOME/docker_volumes/docker-registry/config/backup.sh" >> "$HOME/docker_volumes/docker-registry/logs/backup.log" 2>&1

Give the script the full path to Docker if cron's PATH cannot find it. On Windows, create a daily 03:00 Task Scheduler task under the account that runs Docker Desktop, launching PowerShell with -NoProfile -File and the full script path. Desktop and the computer must be running. Prevent backup, GC and update schedules from overlapping.

Restore test: choose an archive, list it with tar -tzf (Windows: tar.exe -tzf), then extract into a new empty folder, never over the working data. On Linux/Mac use sudo tar -xzf "<archive-path>" -C "<empty-restore-folder>"; on Windows use tar.exe -xzf "<archive-path>" -C "<empty-restore-folder>". These quoted paths are dummy placeholders.

On an isolated Docker host, recreate the saved project with its pinned images, restored bind folders and trusted HTTPS configuration. Point only the test client's DNS at it. Log in and pull a retained image on a clean client; compare its digest with the pre-backup record. Archive listing alone is not a successful restore test. docker-volume-backup offers another scheduling approach.

Performance and resources#

We measured no RAM, CPU, throughput or backup time. Run docker stats docker-registry during representative pushes and pulls; watch host disk space as well. Persistent SSD storage and adequate network capacity are sensible starting points, not measured speed claims.

The documented descriptor-cache option trades metadata lookups against memory and consistency concerns. We leave it disabled because of issue 5010. Before enabling it, test your workload and GC routine on a copy. Set a capacity alert; enabling delete alone does not create a retention policy or automatic private-registry garbage collection.

Issue 5038, now closed, reports slow filesystem tag listing after an upgrade to 3.1.2 with very large tag collections. We have not verified a released fix; benchmark migrations with your actual repository size.

FAQ#

Why does version 3 still use /v2/?

The server version and HTTP API version are different things. Clients continue using the V2 API.

Can every user see every repository?

In this htpasswd setup, authenticated users share access. Choose Harbor when repository/project roles matter.

Does the registry scan images?

This setup stores and serves content. Add scanning in your build workflow with Trivy or Grype and Syft.

Can the cache also store our builds?

Use separate instances. Proxy mode is for upstream pulls, not accepting private pushes.

Is a laptop suitable as the server?

For learning, yes, while Docker is running. Other machines cannot pull when it sleeps; an always-on host is easier for deployments.

Sources#

Checked against the official docs on 2026-12-03.

Try one of these