Connect with us

DevOps

How to create a private Docker registry without https, SSL

In this article, we will create a Linux private docker registry without https, SSL. few months ago when I was trying to set up a private docker registry without https there was no proper guide on the internet, thas why I decided to create this guide.

So let’s start.

Install Docker

first of all, we have to install docker in a Linux box which we are going to use as the docker registry.

you can install docker using this command:

in centos 7,RedHat

in ubuntu

then start the docker service:

you can verify docker installation using this:

private Docker registry without https

Run Docker Registry Image

now we can install the docker registry in this Linux box. actually registry is just a docker container.

so let’s pull it from the docker hub and run. Please check below, for example, docker run command.

-p 5000:5000 –> this is the port mapping from your Linux box port 5000 to container port 5000.

–name linuxteacherregistry –>  you can give any name you want for this

-e REGISTRY_STORAGE_DELETE_ENABLED=true  –> This is an environment variable and will be valuable for you in the feature. we will discuss this later in this article.

registry:2 = docker registry image we are pulling from the docker hub.

private Docker registry without https

now run the above command.it will download the registry image from the docker hub and create your docker registry within a minute. that’s the beauty of docker 🙂

you can verify it using:

docker ps or docker container list  (its the same command but docker ps is the old command.)

you can grep it by using the name you provided earlier.

Congratulations your docker registry is up and running 🙂

Access docker registry without https/SSL

now your private docker registry is running. you can access the docker registry using your Linux box IP or localhost.

But it’s hard to memorize the IP address when we access the docker registry from other Linux boxes.

so now we are going to give a name to the registry.

Let’s add an entry to /etc/hosts file in the servers.

NOTE: you have to add this entry to all /etc/hosts files on the servers which access this docker registry.

you can give any name you want. no need to be it a .com or valid domain.because our traffic is not going through the public internet.

so I’m giving “registry.linuxteacher.com”.

private Docker registry without https

17.17.0.26 = replace it with your Linux box IP which is used to run the Docker registry

registry.linuxteacher.com = replace with any name you want.

Push to the private registry

Now let’s try to push an image to our registry.

first of all download a sample image from the docker hub to test.

Tag It

then you have to tag the image with your private docker registry name and port.

Example:

replace the “registry.linuxteacher.com” with your registry name.

now docker knows the part before “/” is the docker registry name. otherwise, docker will try to push to the docker hub and will get an error message like “unauthorized: authentication required”

Push it.

lets push the image to our registry.

wooh.. you will get an error like a bellow because of docker try to push the image using HTPPS.

Disable HTTPS error message

To avoid the above error, you have to create a daemon.json file or edit that file. file location is this:

/etc/docker/daemon.json

then add bellow entry to it.

Replace the “registry.linuxteacher.com” with your private docker registry name.

NOTE: you have to add the above entry to all your Linux boxes that access this docker registry.

Reload Docker daemon

After that, you have to restart or reload the Docker daemon. otherwise change will not be affected.

Now you can push to your docker registry without an issue using the above push command.

Congratulations!! you have successfully created a private docker registry without https 🙂

when I was creating my registry I had a bunch of questions in my head like,

how to view images in the registry or delete images from registry or view tags of an image?

I think you have some questions like above in your head. 🙂 

so let’s find the answers to the above questions from our next article.

Also, in the previous article, we discussed different between docker add vs copy vs volume. Give it a try 🙂


Continue Reading
Advertisement
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Trending