Containerization is the new standard in software development today, and Docker is the one that runs and orchestrates the containers. It is not advisable to use a public registry like Docker Hub for business-critical applications or enterprise environments considering security issues, storage limitations, and network environments. This is where a Docker Private Registry is needed.
A Docker Private Registry is a on-premises registry installed on an organization’s infrastructure that helps developers and organizations store, manage, and share container images in a secure way. It provides control of the container image, enhanced security, and sound DevOps practices.
This tutorial covers a detailed explanation of Docker Private Registry, benefits, installation, security, best practices, and troubleshooting.
What is a Docker Private Registry?

A Private Docker Registry is a personal repository for storing and holding Docker images, in contrast to public repositories such as Docker Hub. Private registries are utilized by businesses to retain their images, provide security, and enhance performance by reducing reliance on outside services.
An official registry utility offered by Docker is in the format of Docker Distribution, where a private registry is hosted with basic setup.
Why a Private Docker Registry?
The motives for a private registry are the following:
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
- Security & Privacy – Secure sensitive images and limit access within an organization.
- Faster Image Access – Lower latency by storing images close to the deployment point.
- Avoid Docker Hub Rate Limits – Public registries place a pull limitation; private registries remove this restriction.
- Compliance & Governance – Enforce compliance with organizational policies and regulations.
- Customization & Control – Pluggable into current CI/CD pipelines and enforces custom security policies.
Setup Docker Private Registry
Setting up Docker Private Registry is simple with the use of the Docker Distribution project. Below are the steps to deploy a private registry with Docker.
Prerequisites
Make sure the following are available before creating a private registry:
- Docker installed on the system (
docker --version
to confirm). - A Linux box or cloud virtual machine with sufficient storage.
- A domain name (if there’s a secure registry using HTTPS).
Step 1: Running the Docker Registry Container
Docker registry image official from Docker can run as a container. Start an easy private registry with the below command:
docker run -d -p 5000:5000 --name private-registry registry:2
This runs a registry at port 5000, accessible at http://localhost:5000
.
Step 2: Pushing & Pulling Images
After starting the registry, test it by tagging and pushing an image:
- Tag an image that’s running
docker tag ubuntu:latest localhost:5000/ubuntu
- Push the image to the private registry
docker push localhost:5000/ubuntu
- Pull the image from the private registry
docker pull localhost:5000/ubuntu
You have a functional private registry now. It’s not secure and available only via HTTP, though.
Securing the Docker Private Registry
The default registry is HTTP-based, which it should not be in a production environment. Secure your registry with TLS (SSL) and authentication.
Step 1: Let’s Encrypt SSL Configuration

1. Install Certbot
sudo apt update && sudo apt install certbot
2. Get an SSL Certificate

sudo certbot certonly --standalone -d registry.yourdomain.com
3. Get the Registry to Use SSL
Create a config file /etc/docker/registry/config.yml
and provide certificate paths:
http:
addr: :5000
tls:
certificate: /etc/letsencrypt/live/registry.yourdomain.com/fullchain.pem
key: /etc/letsencrypt/live/registry.yourdomain.com/privkey.pem
4. Stop and Restart the Registry
docker stop private-registry
docker rm private-registry
docker run -d -p 5000:5000 --name private-registry \
-v /etc/docker/registry/config.yml:/etc/docker/registry/config.yml \
registry:2
Step 2: Enabling Basic Authentication
To limit access, enable Basic Authentication with htpasswd
.
1. Install htpasswd
tool
sudo apt install apache2-utils
2. Create a User and Password File
htpasswd -Bc /etc/docker/registry/auth/htpasswd myuser
3. Configure the Registry Configuration
Update /etc/docker/registry/config.yml
to include authentication:
auth:
htpasswd:
realm: basic-realm
path: /etc/docker/registry/auth/htpasswd
4. Reload the Registry
docker restart private-registry
You will now be required to authenticate to push and pull images:
docker login registry.yourdomain.com
Best Practices for Running a Private Registry
- Use Image Cleanup – Regularly clean unused images with a garbage collection process.
- Use Image Tagging – Utilize a proper tagging policy to prevent confusion.
- Monitor Registry Performance – Utilize Prometheus or Grafana for monitoring.
- Automatic Image Scanning – Conduct security scanning for vulnerabilities.
- CI/CD Pipeline Integration – Automate image build and deployment.
Resolving Common Issues
1. Registry is Not Accessible
Solution: Open the 5000 firewall port and review logs:
docker logs private-registry
2. Authentication Does Not Work
Solution: Re-generate credentials and check that the htpasswd
file is correct.
3. SSL Issues
Solution: Check if a certificate is valid with:
openssl s_client -connect registry.yourdomain.com:5000
Conclusion
A Private Docker Registry is a valuable resource for organizations that need an effective, managed, and secure means of storing and distributing container images. With a registry that features SSL, authentication, and automation, organizations can enhance security, minimize reliance on public registries, and accelerate DevOps pipelines.
Now that you’ve learned how to deploy, secure, and optimize your private registry, you’re ready for production deployment. Happy containerization!
FAQs
1. How do I create a private registry with AWS, GCP, or Azure?
Rather than self-hosting, you can utilize:
AWS Elastic Container Registry (ECR)
Google Container Registry (GCR)
Azure Container Registry (ACR)
These managed offerings include private registries with inherent security and scalability.
2. What are some best practices for running a private Docker registry?
Use TLS encryption to encrypt image transfers.
Enable authentication to limit access.
Implement automatic backups of registry data.
Perform regular image cleanups to reclaim disk space.
Simplify CI/CD pipelines to automate effortlessly.
3. Can multiple users share a private Docker registry?
Yes, multiple users can share a private registry with authentication turned on. You can set roles and permissions for various users.