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.
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.
There are several places to store your own images. This table can help you decide:
| Your own Docker Registry | Docker Hub | Registry in Forgejo or GitLab | |
|---|---|---|---|
| Where images are stored | On your VPS | At Docker | On your Git server |
| Private images | Yes, all images | Limited, depending on the plan | Yes |
| Web interface | No, only API and Docker commands | Yes | Yes, in the Git server |
| Users and permissions | One account (One-Click App) | Accounts and teams | Permissions follow the repository |
| Effort | Low | None | Requires 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 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.
- 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.
- Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
- Search the app catalog for Docker Registry and click Install app.
- Use a custom subdomain or zap.cloud is already selected, with a random name. Leave this option enabled, because
docker loginrequires HTTPS. Enter a short name, such asregistry. This address will appear in every image name later. - You don’t need to enter anything under App configuration. The app has two Automatically generated values:
SERVICE_USER_REGISTRYandSERVICE_PASSWORD_REGISTRY. - 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/.
The registry requires authentication for every request, including downloads. Without credentials, it rejects docker push and docker pull. To find your credentials:
- Click the gear icon on the app card and go to App environment.
- Under Automatically generated values,
SERVICE_USER_REGISTRYshows the username andSERVICE_PASSWORD_REGISTRYshows 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://:
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.
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.
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:
- Open App environment in the app settings (gear icon).
- Under Custom environment variables, click the plus icon.
- Enter
REGISTRY_STORAGE_DELETE_ENABLEDas the key andtrueas the value. - 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.
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.
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.
- 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 --versionanddocker compose version. - A domain or subdomain whose A record points to your VPS’s IP address (e.g.,
registry.example.com).docker loginrequires HTTPS with a valid certificate.
The registry needs very little computing power. The main consideration is storage space for your images:
| Hardware | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU core | 2 vCPU cores |
| RAM | 512 MB | 1 GB |
| Storage | 10 GB | As much as your images need, plus some extra |
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:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
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.
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:
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:
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:
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.
Check on the server that authentication is working. Without credentials, the registry should return 401:
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:
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.
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:
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.
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.
All images are stored in /opt/registry/data, and the credentials are in /opt/registry/auth. For a consistent backup, briefly stop the registry:
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.
First, read the release notes for the new version. Then update the image version in docker-compose.yml and restart the registry:
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.
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.
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:
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:
curl -u YOUR_USERNAME https://registry.example.com/v2/_catalog
curl -u YOUR_USERNAME https://registry.example.com/v2/myapp/tags/list
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:
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.
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:
- 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.
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:
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:
# 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
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.
- 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.
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.”