How to Host Your Own Docker Hub in Cloud Raya

How can we help?
< All Topics
Print

How to Host Your Own Docker Hub in Cloud Raya

Docker is a popular container application to host an application on a container instead host it into the server. Docker has a free public registry, named Docker Hub that can host custom Docker images.

But, there is a condition that a developer does not want his Docker image publicly available. And then, Docker Registry exists to meet that condition. Docker Registry is an application that manages, stores, and delivering container images in a private environment.

Here are the steps to host the Docker Registry environment or hub in Cloud Raya using Ubuntu Virtual Machine.

Prerequisites

  • Two Ubuntu VM’s acted as private Docker Registry server and the other as a client. In this tutorial there is 2 VM’s :
    Docker Registry – 198.167.141.168 – dockerhub1
    Client – 202.43.249.219 – dockerhub2
  • Docker and Docker-Compose installed on both VM’s.

Step 1 – Installing and Configuring the Docker Registry

To begin with is make a container that contains Docker Registry application running on Docker Registry server with port 5000 (this is optional), with the command :

# docker run -d -p 5000:5000 --restart=always --name registry registry:2

Then, pull an image from Docker Hub, for example like Alpine image like below :

# docker pull alpine:latest

If the pulling process is success you will getting output like below :

REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
alpine        latest    389fef711851   10 days ago     5.58MB

Give a new tag into that Alpine image based on Docker Registry location, in this case, is localhost, with the command :

# docker tag alpine:latest localhost:5000/alpine:latest

If you are running the “docker images” once again, you will get a result like this :

REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
localhost:5000/alpine   latest    389fef711851   10 days ago     5.58MB

After that, push that custom image into Docker Local Registry, with command :

# docker push localhost:5000/alpine:latest

If successful, that custom Docker Images will be saved into your own made Docker Registry server.

The push refers to repository [localhost:5000/alpine]
777b2c648970: Pushed 
latest: digest: sha256:074d3636ebda6dd446d0d00304c4454f468237fdacf08fb0eeac90bdbfa1bac7 size: 528

Step 2 – Pulling Images from the Docker Registry Server

Move the environment into the client VM. And then continues the steps by pulling the custom image from the Docker Registry server, with the command :

# docker pull 198.167.141.168:5000/alpine:latest

You will getting error response like this :

Error response from daemon: Get https://198.167.141.168:5000/v2/: http: server gave HTTP response to HTTPS client

That error response caused by Docker default configuration only allowing pull process using a secure connection (HTTPS). Because the Docker Registry service that setup on the Docker Registry server (VM 198.167.141.168) only using an HTTP connection, it will make the pull process into that server failed.

So, in order to do the pull process from the Docker Registry server using an HTTP connection, we have to add the /etc/docker/daemon.json file with content like below :

{
   "insecure-registries" : ["198.167.141.168:5000"]
}

The IP Address section is from the IP Address of the Docker Registry server. Save that file, and then restart the Docker service with the command :

# systemctl restart docker.service

After that, try the pull process from the Docker Registry server once again. Since the Docker Registry server IP Address is added into /etc/docker/daemon.json to use the pull process using an HTTP connection, the result will be succeeded like below :

REPOSITORY                    TAG       IMAGE ID       CREATED         SIZE
198.167.141.168:5000/alpine   latest    389fef711851   10 days ago     5.58MB

As we can see, the alpine custom Docker Images is displayed on the docker images list on VM Client (VM 202.43.249.219) that indicating the custom image is successfully pulled from our Docker Registry server.

In the future, this Docker Registry server can be used to store and deliver another custom Docker Images for multiple application development.

Congratulations! You have now set up and configured your own Docker Hub (Docker Registry) on CloudRaya Virtual Machine.

Conclusion

In this guideline, we have installed and configured our own Docker Hub (Docker Registry) on Virtual Machine CloudRaya environment for serving custom images and containers using Docker Registry as storage and delivering tools to provide custom containers in the application development.

Table of Contents

Comments are closed.

Ready, Set, Cloud

Ready, Set, Cloud