Skip to content

Set Up a Docker Registry on a Linux Server – Private Registry for Your Own Images

Set up your own Docker Registry on a Linux VPS with the One-Click App or Docker Compose. Configure authentication, upload and download images, connect Coolify and CI, and manage storage with garbage collection.

29 November 202613 min read1 Views0 helpful

Introduction

A Docker Registry is a storage location for container images. Use docker push to upload an image and docker pull to download it to another server. Docker Hub is the best-known public registry. With your own registry on your VPS, your images stay under your control: they remain private, have no download limits, and are accessible only to people and servers that know the credentials. The software behind it is called Distribution (formerly “Docker Registry”); other registries are built on it too.

In this guide, we’ll show you two ways to set one up: the simple One-Click App option, which makes the registry available with authentication and HTTPS in just a few minutes, and a manual installation using Docker Compose. After that, you’ll upload your first image, use it on other servers, and manage storage with garbage collection.

When a private Docker Registry on a VPS makes sense

A private registry is useful as soon as you build your own images and need them on multiple servers or in automated workflows. A VPS is a good fit if:

  • You want to keep your images private. Applications containing your own code or internal settings don’t belong in a public registry.
  • You want to distribute images between servers. Build an image once, upload it to your registry, and download it to each server with docker pull.
  • You want a CI pipeline to build images. GitHub Actions, Forgejo Actions, or your own runner can upload the finished image to your registry, and your servers can download it from there.
  • You don’t want to be subject to limits. Your own registry has no download limits and no fees per private repository.
  • You want to deploy fixed versions, such as myapp:1.4.2, and keep older versions for a quick rollback.

A private registry is less useful if you only use ready-made public images such as nginx or postgres. You can download those directly from Docker Hub. The registry is also not a web interface for managing containers. For that, use Portainer or Coolify.

Your own registry, Docker Hub, or a registry in Forgejo and GitLab?

There are several places to store your own images. This table can help you decide:

Your own Docker RegistryDocker HubRegistry in Forgejo or GitLab
Where images are storedOn your VPSAt DockerOn your Git server
Private imagesYes, all imagesLimited, depending on the planYes
Web interfaceNo, only API and Docker commandsYesYes, in the Git server
Users and permissionsOne account (One-Click App)Accounts and teamsPermissions follow the repository
EffortLowNoneRequires a complete Git server

If you already run Forgejo or GitLab, you can also use their built-in registry. Your own Docker Registry is the lightweight option if you only need private image storage.

The easy way: Docker Registry as a One-Click App

The quickest way to set up your own registry is through your VPS’s One-Click Apps. The app is immediately accessible over HTTPS using a domain and protects all access with a username and password that are generated automatically during installation. You don’t need a reverse proxy, certificate, or password file.

Requirements

  • A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set Up One-Click Apps for instructions.
  • Enough free storage for your images. The registry itself requires very little computing power; its storage needs depend only on the number and size of your images.
  • Docker on the computer or server you’ll use to upload images. See Install Docker.

Install

  1. Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search the app catalog for Docker Registry and click Install app.
  3. Use a custom subdomain or zap.cloud is already selected, with a random name. Leave this option enabled, because docker login requires HTTPS. Enter a short name, such as registry. This address will appear in every image name later.
  4. You don’t need to enter anything under App configuration. The app has two Automatically generated values: SERVICE_USER_REGISTRY and SERVICE_PASSWORD_REGISTRY.
  5. Click Queue installation.

After about a minute, the app card will show “Online.” If you open the Access link, you’ll see a blank page. That’s normal: the registry has no web interface and only responds to Docker and API requests under /v2/.

Find your credentials and sign in

The registry requires authentication for every request, including downloads. Without credentials, it rejects docker push and docker pull. To find your credentials:

  1. Click the gear icon on the app card and go to App environment.
  2. Under Automatically generated values, SERVICE_USER_REGISTRY shows the username and SERVICE_PASSWORD_REGISTRY shows the password. Click the eye icon to display a value or the icon next to it to copy it.

Then sign in on your computer or server. Replace registry.example.com with your app’s address, without https://:

Code
docker login registry.example.com -u YOUR_USERNAME

Docker will ask for the password and display Login Succeeded. Docker saves the login in ~/.docker/config.json, so you only need to do this once on each computer. Because the app has a valid certificate, you don’t need to configure it as an “insecure” registry.

Warning: These credentials grant full access

The One-Click App has exactly one account. Anyone who knows the username and password can read and overwrite all images and, if you allow deletion, delete them too. Share the credentials only with servers and pipelines you trust, and store them as a secret there—never in plain text in a repository.

Allow image deletion

By default, the registry does not allow image deletion. A deletion request through the API returns “The operation is unsupported,” and without deleted images, garbage collection cannot free up storage. To remove old images, enable deletion once:

  1. Open App environment in the app settings (gear icon).
  2. Under Custom environment variables, click the plus icon.
  3. Enter REGISTRY_STORAGE_DELETE_ENABLED as the key and true as the value.
  4. Click Save. The app will restart with the new setting, and your images will remain intact.

For instructions on deleting old images and freeing up storage afterward, see “Storage and garbage collection” below.

Updates and backups

Update the registry in the app settings (gear icon), under App update. Click Check for updates, then install a new version with Apply update. If the app is up to date, there isn’t a newer version in the app catalog yet.

All images are stored in the app’s registry-data volume and are retained through updates and restarts. On the VPS, you’ll find it under /var/lib/docker/volumes/; its name starts with a random app identifier and ends in _registry-data. Back up the VPS before making major changes, for example using Backups in the dashboard. You don’t necessarily need to back up images that you can rebuild at any time. Images whose source code is no longer available are important to back up.

Manual installation

The rest of this guide covers a manual installation of the registry with Docker Compose on your VPS. For example, you might use this method if you don’t use One-Click Apps on the server or want to run the registry behind your own reverse proxy.

Requirements

  • A Linux VPS running Debian or Ubuntu, with SSH access. See First SSH Access.
  • Docker and Docker Compose (Compose v2). See Install Docker. Check the installation with docker --version and docker compose version.
  • A domain or subdomain whose A record points to your VPS’s IP address (e.g., registry.example.com). docker login requires HTTPS with a valid certificate.

The registry needs very little computing power. The main consideration is storage space for your images:

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM512 MB1 GB
Storage10 GBAs much as your images need, plus some extra

Prepare the firewall

The registry listens on port 5000. You don’t need to open this port if you use a reverse proxy as described below. With ufw, allow only SSH and the ports used by the reverse proxy:

Code
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Warning: Docker bypasses ufw

Ports published by Docker using ports: are accessible from the outside even if ufw blocks them. Docker adds its own rules ahead of those from ufw. Therefore, bind the registry to 127.0.0.1 as described below. For more about the firewall, see Managing the Firewall on Linux.

Install with Docker Compose

Create a directory for the registry and generate the password file. The registry image does not include the htpasswd tool, so you’ll briefly use the Apache web server image for this. The command will ask you for the password twice and won’t display it:

Code
mkdir -p /opt/registry/auth /opt/registry/data
cd /opt/registry
docker run --rm -it -v "$PWD/auth:/auth" --entrypoint htpasswd httpd:2 -Bc /auth/htpasswd myuser

Replace myuser with your username. The registry only accepts passwords in bcrypt format, which the -B option ensures. To add more users, run the command without c (-B instead of -Bc); otherwise, you’ll overwrite the file.

Now create the docker-compose.yml file, for example with nano docker-compose.yml:

Code
services:
  registry:
    image: registry:3.1.2
    restart: unless-stopped
    environment:
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
      REGISTRY_STORAGE_DELETE_ENABLED: "true"
    volumes:
      - ./data:/var/lib/registry
      - ./auth:/auth:ro
    ports:
      - "127.0.0.1:5000:5000"

Here’s what the important lines mean:

  • registry:3.1.2: The official image at a fixed version. This lets you choose when to update.
  • REGISTRY_AUTH: htpasswd: Enables username and password authentication. Without these lines, anyone who can reach the registry can upload and download images.
  • REGISTRY_AUTH_HTPASSWD_PATH: The path to the password file inside the container.
  • REGISTRY_STORAGE_DELETE_ENABLED: Allows images to be deleted through the API. Without this line, you won’t be able to free up storage later.
  • ./data:/var/lib/registry: All images are stored here. Back up this directory.
  • 127.0.0.1:5000:5000: The registry is only accessible from the server itself, and from outside only through the reverse proxy.

Start the registry:

Code
docker compose up -d
docker compose logs -f registry

The log will show listening on [::]:5000 when the registry is ready. Exit the log view with Strg+C. The “No HTTP secret provided” warning only applies to multiple registries behind a load balancer and is harmless on a single server.

First test

Check on the server that authentication is working. Without credentials, the registry should return 401:

Code
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:5000/v2/

Docker allows connections to 127.0.0.1 without HTTPS. So, for a first test on the server itself, sign in directly:

Code
docker login 127.0.0.1:5000 -u myuser
docker pull hello-world
docker tag hello-world 127.0.0.1:5000/test/hello:1
docker push 127.0.0.1:5000/test/hello:1

You can access the registry from other computers over HTTPS after completing the next step.

Access over HTTPS through a reverse proxy

To access the registry from outside, put a reverse proxy with a valid certificate in front of it. For the basics, see Set Up a Reverse Proxy with nginx and Create an SSL Certificate (Let's Encrypt). Here’s a server block for nginx:

Code
server {
    listen 80;
    server_name registry.example.com;

    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;
    }
}

Then get the certificate with certbot --nginx -d registry.example.com. Certbot will add HTTPS and HTTP redirection to the block. The two lines above are important for a registry: client_max_body_size 0 removes the request size limit; otherwise, nginx will stop large image layer uploads with “413 Request Entity Too Large.” proxy_read_timeout 900 prevents timeouts during slow uploads.

Tip: Further restrict access

If only your own servers and pipeline need the registry, you can use allow and deny in nginx to restrict /v2/ to their IP addresses. Find more tips in Linux Security Tips.

Back up your data

All images are stored in /opt/registry/data, and the credentials are in /opt/registry/auth. For a consistent backup, briefly stop the registry:

Code
cd /opt/registry
docker compose stop
tar czf /root/registry-backup-$(date +%F).tar.gz data auth docker-compose.yml
docker compose start

Don’t store the backup only on the VPS itself. If you have many large images, it may be enough to back up only the images you can’t rebuild at any time.

Update the registry

First, read the release notes for the new version. Then update the image version in docker-compose.yml and restart the registry:

Code
cd /opt/registry
docker compose pull
docker compose up -d

The images in the data directory will be retained. Find the installed version with docker compose exec registry registry --version.

Upload, use, and clean up images

After setting up the registry, you can upload your own images, use them on other servers, and keep storage usage low. The steps are the same for the One-Click App and the manual installation. In the examples, registry.example.com represents your registry’s address.

Tag and upload an image

An image belongs to a registry when the registry’s name appears at the beginning of the image name. To do this, give an existing image an additional name (tag) and upload it:

Code
docker build -t myapp:1.0 .
docker tag myapp:1.0 registry.example.com/myapp:1.0
docker push registry.example.com/myapp:1.0

The registry address comes before the slash, followed by the repository name and, after the colon, the version. You can group repositories using additional slashes, for example, registry.example.com/team/backend:2.3. Query the API to see which repositories and versions are in your registry:

Code
curl -u YOUR_USERNAME https://registry.example.com/v2/_catalog
curl -u YOUR_USERNAME https://registry.example.com/v2/myapp/tags/list

Use images on other servers

On each server that needs your images, sign in once with docker login registry.example.com. After that, download images as usual with docker pull registry.example.com/myapp:1.0. Enter the full image name in your docker-compose.yml file:

Code
services:
  app:
    image: registry.example.com/myapp:1.0
    restart: unless-stopped

docker compose pull and docker compose up -d will automatically use the saved login. Use fixed versions instead of latest. That way, you’ll always know which version is running and can quickly roll back to the previous one.

Connect the registry to Coolify and CI

Coolify can also start applications from ready-made images. To use an image from your registry, sign in once on the server where Coolify starts the application with docker login registry.example.com, then enter the full image name in Coolify, for example, registry.example.com/myapp:1.0.

In a CI pipeline, store the username and password as secrets. Here’s a snippet for GitHub Actions that builds and uploads an image:

Code
- uses: docker/login-action@v3
  with:
    registry: registry.example.com
    username: ${{ secrets.REGISTRY_USER }}
    password: ${{ secrets.REGISTRY_PASSWORD }}
- uses: docker/build-push-action@v6
  with:
    push: true
    tags: registry.example.com/myapp:${{ github.sha }}

The steps are similar in Forgejo Actions. For information on setting up your own runners on a VPS, see the guides for Forgejo and GitLab.

Storage and garbage collection

Every uploaded image remains stored until you delete it. So, if your pipelines create a new image for every commit, the registry can grow quickly. Cleaning up takes two steps: first delete old versions, then run garbage collection to free up storage. Deletion must be enabled first (see above or REGISTRY_STORAGE_DELETE_ENABLED in the Compose file).

Delete a version using its digest, a unique checksum. The registry returns the digest when you query the version:

Code
curl -sI -u YOUR_USERNAME \\
  -H "Accept: application/vnd.oci.image.index.v1+json" \\
  -H "Accept: application/vnd.oci.image.manifest.v1+json" \\
  -H "Accept: application/vnd.docker.distribution.manifest.list.v2+json" \\
  -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \\
  https://registry.example.com/v2/myapp/manifests/1.0 | grep -i docker-content-digest

curl -u YOUR_USERNAME -X DELETE https://registry.example.com/v2/myapp/manifests/DIGEST

The registry responds with 202, and the version disappears from the list. However, this does not free up the storage yet. To do that, run garbage collection on the VPS. With --dry-run, it first shows you what it would delete:

Code
# One-Click App: find the container name (starts with registry-)
docker ps --format '{{.Names}}' | grep '^registry-'
docker exec CONTAINER_NAME registry garbage-collect --dry-run /etc/docker/registry/config.yml
docker exec CONTAINER_NAME registry garbage-collect --delete-untagged /etc/docker/registry/config.yml

# Manual installation
cd /opt/registry
docker compose stop
docker compose run --rm registry garbage-collect --delete-untagged /etc/distribution/config.yml
docker compose start
Warning: Don’t upload images during garbage collection

If someone uploads an image while garbage collection is running, it may be corrupted. Run garbage collection during a quiet period when no pipeline is active. For a manual installation, stop the registry first as shown above.

Limitations

  • No web interface: By default, the registry has no interface for browsing or deleting images. You’ll use Docker commands and the API under /v2/.
  • One account for the One-Click App: There is exactly one user with full permissions. The registry doesn’t provide per-repository permissions or separate accounts for individual users. For that, use the registry in Forgejo or GitLab.
  • No automatic cleanup: The registry doesn’t delete old images on its own. Plan to delete old versions and run garbage collection regularly.
  • Not a Docker Hub mirror: In this setup, the registry only stores your own images and doesn’t forward requests to Docker Hub.

Conclusion

You’ve set up your own private Docker Registry on your VPS, uploaded your first image, used it on another server, and learned how to delete old versions and free up storage. From now on, you can build images once and distribute them to all your servers without making them public.

Prefer to skip the Docker setup? Take the easy route with the One-Click App, as described above under “The easy way: Docker Registry as a One-Click App.”

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the quickest option: the registry is available over HTTPS using a domain, and the username and password are generated automatically. You don’t need a reverse proxy, certificate, or password file, and you can install updates in the app settings under App Update. Manual installation with Docker Compose is useful if you don’t use One-Click Apps on your server, want to manage multiple users in a custom password file, or want to run the registry behind your own reverse proxy.
For the One-Click App, click the gear icon on the app card and open App Environment. Under Automatically generated values, SERVICE_USER_REGISTRY contains the username and SERVICE_PASSWORD_REGISTRY contains the password. Use these credentials with docker login. For a manual installation, create the username and password yourself with htpasswd in the auth/htpasswd file.
No. The One-Click App requires authentication for every request, including docker pull. Without credentials, the registry responds with “authentication required” or “no basic auth credentials.” For a manual installation, this is only true if you set the REGISTRY_AUTH and REGISTRY_AUTH_HTPASSWD_PATH variables as shown in the guide. Without them, anyone who can reach the registry can access it.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.