Back to articles
DevOps & Systems

Comprehensive Guide to Using Private Docker Registry with UI on VPS for Enterprises

This detailed guide covers setting up and operating a private Docker Registry with a user-friendly UI on a VPS, ideal for enterprises needing control over container images, ensuring...

DPTCloud Engineering4 min read
Comprehensive Guide to Using Private Docker Registry with UI on VPS for Enterprises

Image credit: congerdesign · Pixabay Content License

This detailed guide covers setting up and operating a private Docker Registry with a user-friendly UI on a VPS, ideal for enterprises needing control over container images, ensuring internal security, and optimizing CI/CD workflows. The guide includes installation, SSL configuration, Nginx integration, and management via Portainer or Docker UI, all deployed on NVMe Cloud VPS for high performance and scalability.

Introduction to Private Docker Registry and Enterprise Needs

A private Docker Registry enables enterprises to store and distribute internal container images without relying on Docker Hub. This ensures code security, compliance with internal policies, and faster image deployment within internal environments. Deploying a private registry on a high-performance NVMe Cloud VPS offers stability, scalability, and cost-effective infrastructure suitable for small to medium development and production systems.

Prerequisites and Setup Steps

To deploy a private Docker Registry with UI on a VPS, you need:

  • A NVMe Cloud VPS (see: NVMe Cloud VPS for Docker, Nginx & Databases)
  • A public IP or domain name (preferably with DNS configured)
  • Docker and Docker Compose installed
  • SSL certificate (use Let's Encrypt)
  • Proxy software like Nginx or Traefik for security and routing

Ensure your VPS is updated and has the required tools:

sudo apt update && sudo apt upgrade -y
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker
sudo systemctl start docker

Setting Up Private Docker Registry with Portainer UI

Portainer provides a powerful web UI for managing Docker environments. Integrating it with a private Docker Registry allows visual monitoring, management, and distribution of images.

First, create a docker-compose.yml file to deploy the Registry and Portainer:

version: '3.8'

services:
  registry:
    image: registry:2
    container_name: docker-registry
    ports:
      - "5000:5000"
    volumes:
      - ./data:/var/lib/registry
    restart: always
    environment:
      REGISTRY_HTTP_ADDR: 0.0.0.0:5000
      REGISTRY_HTTP_TLS_CERTIFICATE: /certs/server.crt
      REGISTRY_HTTP_TLS_KEY: /certs/server.key
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
    volumes:
      - ./certs:/certs
      - ./auth:/auth
      - ./data:/var/lib/registry

  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./portainer_data:/data
    restart: always

Start the services:

docker-compose up -d

Secure the registry by creating a user account:

sudo apt install apache2-utils -y
htpasswd -B -c ./auth/htpasswd admin

Ensure directories certs, auth, and data are created before running.

Integrating Nginx and SSL for Secure Access

To access the private registry securely over HTTPS, use Nginx as a reverse proxy. Create an Nginx configuration file:

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

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

    location / {
        proxy_pass http://localhost:5000;
        proxy_set_header Host $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;
    }

    location /v2/ {
        proxy_pass http://localhost:5000;
        proxy_set_header Host $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;
    }
}

Obtain an SSL certificate using Let's Encrypt:

sudo certbot certonly --standalone -d registry.yourdomain.com

Restart Nginx:

sudo systemctl restart nginx

Verification and Testing

Verify the private registry is working:

  1. Access Portainer at http://your-vps-ip:9000
  2. Log in with your credentials
  3. Push an image:
docker tag myimage:latest registry.yourdomain.com/myimage:latest
docker login registry.yourdomain.com
docker push registry.yourdomain.com/myimage:latest

If successful, the image will appear in Portainer or the Registry UI.

Troubleshooting and Maintenance

Common issues:

  • Cannot push image: Check SSL certificates, Nginx config, and login credentials.
  • Portainer does not show containers: Ensure the Docker socket is correctly mounted.
  • Registry not receiving requests: Check logs: docker logs docker-registry.

For maintenance, back up the data and auth directories regularly, and update Docker and Portainer versions.

References

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478