Containers Linux

How to Set up Private Docker Registry

PRIVATE-DOCKER-REGISTRY

When created, container images are saved in a location where they can be accessed for more innovation and updates. Furthermore, you can share these images with multiple users across different hosts because developers and testers require access to images during various development and testing phases. Thus, you can use this shared storage location with a software solution that provides security features and image version control via tags. In addition, image repositories are collections of images that are part of the same project or are grouped according to context. At the same time, a prefix to the image name identifies the repository. Image registries, on the other hand, hold image repositories. So, here’s a guide on how to set up a private docker registry.

You can find other similar guides here: How to Fix MS Excel Crash Issue and How to Fix Hyper-V Virtual Machine Stuck in Stopping State and How To Install Nextcloud on a Linux system also How to install Zabbix Monitoring Tool on a Linux System and How to install Golang on a Linux System

Find more guides here: How to reveal the WiFi password of the Network you are connected to in Windows and How to install Zabbix Monitoring Tool on a Linux System and How to Install Docker Portainer on Linux, and How to Install MongoDB on a Linux System also How to install AnyDesk on a Linux Machine and How to install Golang on a Linux System

Steps to Set up a Private Docker Registry

Here’s a step-by-step guide to setting up a private docker registry.

Step 1: Pull the docker registry image from docker hub

sudo docker pull distribution/registry
How to Set up a Private Docker Registry-registry
docker pull

Step 2: Run Docker’s registry container image

Then, let’s create a private registry using Docker’s registry container image with the command:

 docker run -d -p 5000:5000 --restart=always --name registry registry:2
How to Set up a Private Docker Registry-dockerrun
docker run

We mapped the registry’s port 5000 to the host port5000 while it was running in a “registry” container so that we could access it via localhost.

Step 3: Populate the registry

There are currently no images in the private registry. So, let’s populate it by retrieving an image from the public registry Docker Hub, tagging it, and pushing it into the private registry while also listing local cache registries to validate

docker image pull alpine:3.14
How to Set up a Private Docker Registry-docker-alpine
alpine

Afterwards, verify what we have with the command:

docker images
How to Set up a Private Docker Registry-alpine
docker images

Step 4: Set up Private Docker Registry by tagging the image

Then, tag the newly pulled image:

docker image tag alpine:3.14 localhost:5000/myalps
How to Set up a Private Docker Registry-tag
alpine tagged

In addition, verify this with docker images

How to Set up a Private Docker Registry-docki
docker images

Step 5: Push the tagged image

Subsequently, push the newly tagged image to the private registry:

docker image push localhost:5000/myalps
pushed-1
pushed

Step 6: Set up Private Docker by removing cached image

Then, we will remove cached images alpine 3:14 and localhost:5000/myalps

 docker image rm alpine:3.14
rm
rm alpine
 docker image rm localhost:5000/myalps
rm-alp
rm localhost

Afterward, verify with docker images

sudo docker images
sudorrr
alpine removed

Step 7: Pull the images

Let’s pull the images from the private registry

sudo docker image pull localhost:5000/myalps
pulledpr
localhost from private repo

Verify this with docker images

taggedlocal
image from private repo

Step 8: remove docker images

Let’s remove images that are no longer needed after successfully validating that the private registry can store container images and be used to push and pull images to and from it.

docker image rm -f registry:2
dockerrm
docker rm

We can also do the same with the tagged image using the command:

docker image rm localhost:5000/myalps
taggeduuu
tagged image removed

Summary

In conclusion, images need to be stored after they have been created, and a perfect place to store container images will be a private docker registry. The steps to create one are shown above. You can set up a private docker registry with the steps mentioned above.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x