Configure Docker Private Registry in Linux 8

Share on Social Media

In this article, you will learn how to configure Docker Private Registry in Rocky Linux 8. #centlinux #linux #docker

What is Docker Private Registry? :

Docker creates containers from Docker images. These images are provided by Docker Hub, a centralized public registry that contains various official and unofficial images of almost every software in the world. However, there are situations, when you require an on-premises Docker Private Registry to create and share custom docker images amongst your organizational units.

Docker Private Registry has a few advantages over Docker Hub, some of them are:

  • Since, the Docker Registry is located on premises, therefore it increases availability and speed.
  • Organization’s private images are kept within the Organization.
  • Provides user authentication to restrict unauthorized access.
  • Provides SSL based encryption for better security.

Here, we are using the Docker Engine CE to configure a Private Docker Registry. Therefore, it is advised that you should read Docker Deep Dive (PAID LINK) for some basic level understanding of Docker technology.

Recommended Online Training: Hands on With Docker & Docker Compose From a Docker Captain

Environment Specification:

We are using a minimal Rocky Linux 8 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux 8.6 (Green Obsidian)
  • Hostname –
  • IP Address – /24

Updating Linux Software Packages:

We are using the same Linux based Docker Server that we have configured in our previous installation guide.

By using a ssh client, connect with as root user.

Refresh yum cache of your Linux server.

# dnf makecache
Rocky Linux 8 - AppStream                       1.9 kB/s | 4.8 kB     00:02
Rocky Linux 8 - BaseOS                          1.0 kB/s | 4.3 kB     00:04
Rocky Linux 8 - Extras                          974  B/s | 3.5 kB     00:03
Rocky Linux 8 - Extras                          2.7 kB/s |  11 kB     00:03
Docker CE Stable - x86_64                       5.0 kB/s | 3.5 kB     00:00
Metadata cache created.

Execute following command to update Linux software packages.

# dnf update -y

Check the Linux Kernel and Operating System versions.

# uname -r

# cat /etc/system-release
Rocky Linux release 8.6 (Green Obsidian)

Check the version of Docker that is being used in this article.

# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:03:11 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:29 2022
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
  Version:          0.19.0
  GitCommit:        de40ad0

Configure Docker Private Registry:

List the locally available Docker images in your server.

# docker images

Docker Hub provides an image for Docker Registry.

You can download it and use to create your on-premises Docker Private Registry.

Pull the registry image from Docker Hub.

# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
2408cc74d12b: Pull complete
ea60b727a1ce: Pull complete
c87369050336: Pull complete
e69d20d3dd20: Pull complete
fc30d7061437: Pull complete
Digest: sha256:bedef0f1d248508fe0a16d2cacea1d2e68e899b2220e2258f1b604e1f327d475
Status: Downloaded newer image for registry:latest

Create a directory to use as a consistent storage for Docker Containers.

# mkdir -p /opt/docker/containers/docker-registry/registry

Start the Docker Container with following command.

# docker run -d 
> --name docker-registry 
> --restart=always 
> -p 5000:5000 
> -v /opt/docker/containers/docker-registry/registry:/var/lib/registry 
> registry

The service port 5000/tcp of Registry container is mapped with 5000/tcp of Docker host.

Therefore, you have to allow this service port in Linux firewall, so the network machines can access it.

# firewall-cmd --permanent --add-port=5000/tcp
# firewall-cmd --reload

Now, pull an image from Docker Hub. 

We prefer to pull Alpine Linux image, because it is smaller in size.

# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
2408cc74d12b: Already exists
Digest: sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
Status: Downloaded newer image for alpine:latest

Now, tag the alpine image as follows, and make it ready to add into your Docker Private Registry.

# docker tag alpine:latest localhost:5000/alpine

Push the Alpine image into Local Docker Registry.

# docker push localhost:5000/alpine
The push refers to repository [localhost:5000/alpine]
2408cc74d12b: Pushed
latest: digest: sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c size: 527

Get the list the locally available images of Alpine Linux.

# docker images | grep alpine
alpine                  latest    e66264b98777   5 weeks ago   5.53MB
localhost:5000/alpine   latest    e66264b98777   5 weeks ago   5.53MB

You can see that, one image is available from Docker Hub while the other is available via your Docker Private Registry.


In this article, you have learned how to configure Docker Private Registry in Rocky Linux 8.