Docker Registry | What are Docker Registries and Docker hub?


Docker Registries such as Docker hub are stateless and scalable server-side storage units that stores and lets you distribute Docker images. They are storage and distribution systems that are made up of Docker repositories. A Docker repository is a set or collection of all the versions of a specific image. The same image might have different versions and all of them are identified by different tags.

If we look at the statistics, from November 2019 to July 2020, the total number of image pulls made from the Docker hub grew from 130 billion to a whopping 242 billion. This shows how popular Docker containers have become. To use Docker registries and other Docker tools and utilities, its very essential to understand the basics of Docker. What are Docker registries? What’s the purpose of the Docker hub?

In this article, we will answer all these questions in detail. Before we move ahead, make sure you understand What is Docker? and What are Docker Images?.

If you don’t have Docker installed, you can refer to these guides to install Docker on your system.

  1. How to install Docker on Ubuntu/Linux?
  2. How to install Docker on Windows?

What are Docker Registries?

As discussed, Docker registries are used to store image repositories and it makes it very easy to distribute them. Any authenticated user can push or pull images to and from Docker registries. Once a user has created an account on the Docker hub, he can create his own repository.

There are two types of repositories that you can create in Docker – Public and Private repositories. If you push an image to a public repository, anybody on the Docker hub can pull and use these images. If you push an image to a private repository, only users that you authorize can have access to those images.

The Docker Images stored inside Docker registries are available in different tagged versions. For example, in the Docker hub, there is a repository for Ubuntu images that contains all the versions of Ubuntu identified by their unique tags.

We can access several important images from the Docker hub registry such as Ubuntu, Fedora, CentOS, Nginx, Apache, MySQL, Java, Python, PHP, etc. Docker registries house several official and vendor-specific images.

Docker registries provide a centralized source for managing and storing images. This helps them to enable tighter version control. Consequently, it becomes easier to manage and distribute thousands of Docker images. Additionally, there are many public registry services that offer additional features. These features help us to automate the build and deployment processes and hence, they improve the overall security as well.

We can even create our own private Docker registry in our local machine. Docker allows us to pull an image called registry. When we create a container associated with the registry image, we can tag our existing images with localhost:<port>/<image-name> and when we execute a Docker push command to these images, it will automatically get stored inside the registry container. Hence, this container will now act as a separate private registry for us.

Why should we use Docker Registries?

As already discussed, Docker registries helps us to store, manage, and distribute Docker images very easily. Some benefits of using Docker registries are –

  1. We can tightly control the versions of images and where to store them. Similar images can be stored together as a repository.
  2. It allows us to fully own the image distribution pipeline.
  3. We can integrate the image storage and distribution pipelines with our own development workflow.
  4. We can save our container environments that host our applications as Docker images and push them to Docker registries. This allows us to easily share our images with our team members.
  5. They also help us if we want to deploy a new Docker image quickly over a huge cluster of server nodes or machines.
  6. It’s the best and fastest way to distribute images inside an isolated network.

What is Docker hub?

Docker hub is the official Docker registry by Docker Inc. It allows authenticated users to create and manage public and private repositories. It also provides other features such as automated builds, creation of organization accounts, and integration of repositories with version control systems like Github and Bitbucket. To build a private repository, users can choose subscription plans.

Docker hub is the largest repository that stores thousands of Docker images. They have a plethora of content sources such as community developers, independent software vendors (ISV), and open-source projects.

Anyone can access a public repository running Docker. An typical Docker image name has the following format – <organization or user-name>/<image-name>:<tag-name>. For instance, the command “docker pull ubuntu/ubuntu:20.04“will pull the Ubuntu image with tag 20.04 from the Ubuntu repository. There are thousands of public images available in the Docker hub. If you create a private repository, you can restrict the access to the repository to only the creators or the members of the organization.

We can perform automated image builds, This can be done if our Docker hub repositories are connected to a version control management system like Github or Bitbucket. This can be done if we have a build context with the Dockerfile and all the other application files in the same folder.

When we perform a commit in the source repository, it will automatically trigger a build in the Docker hub. The Docker hub registry also allows us to scan images stored inside the private repositories automatically for vulnerabilities. They produce comprehensive reports detailing all the vulnerabilities that are detected in each image layer sorted by severity level.

Docker Hub Features

The highlighting features of Docker Hub are –

  • Repositories: We can push or pull similar container images to repositories.
  • Teams & Organizations: Docker hub allows us to manage the access to private repositories accessible to only the organization members.
  • Official Images: We can easily pull and use thousands of high-quality official Docker images.
  • Publisher Images: There are tons of other high-quality images provided by external vendors.
  • Builds: Docker hub allows us to create automatic builds from source control repositories such as GitHub and Bitbucket and we can push them to our Docker Hub repositories.
  • Webhooks: We can enable trigger actions that can be performed after a successful push to any repository and integrate the Docker Hub repositories with third-party services.

Why should we use Docker Hub?

Here are a few reasons why should you use Docker Hub instead of other public Docker registries.

  1. Thousands of trusted, high-quality official and vendor-specific images.
  2. The free plan provided by Docker allows us to create unlimited public repositories and a single private repository with a maximum of 3 collaborators. This proves to be useful especially for basic testing.
  3. Built-in security features such as vulnerability scans, audit-logs, and multifactor authentication (MFA).
  4. Integrations with third-party services, automated builds. build triggers, webhooks, etc.

How to create a Docker Hub repository?

You can now check out the step-by-step instructions to build a Docker hub repository and easily get started with Docker hub.

We can use the Docker ID to access our Docker hub repositories. We can then explore all the Docker images that are provided by the community and other verified publishers.

Dockerhub Docker registries signup
Docker Hub Signup
  • Click on Create a Repository button.
Create Docker Hub Repository
Create Docker Hub Repository
  • Name it <your-username>/<repo-name>. Choose the visibility type and click on create repository.
Docker hub repository
Docker hub repository

Here, we have created a repository called sample.

$ docker build -t <your_username>/<repo-name> .
$ docker run <your_username>/<repo-name>
$ docker push <your_username>/<repo-name>

This will push your Docker Image to the Docker Hub repository. In this example, we have pulled an Ubuntu Image from Dockerhub and tagged it as myubuntu. The final image name becomes – iamrj846/sample:myubuntu.

  • We will now be able to see the image in our repository.
Pushing Image to Docker hub
Pushing Image to Docker hub

Other Public Docker Registries

There are several other companies that host paid online Docker registries that are available publicly. There are several popular cloud providers such as AWS and Google. They also offer their own hosting services for containers. Some of the popular ones are –

  1. Google Container Registry (GCR) 
  2. Amazon Elastic Container Registry (ECR) 
  3. Azure Container Registry (ACR)
  4. Private Docker Registry
  5. CoreOS Quay

Final Thoughts!

In this article, we discussed Docker registries and the official registry provided by Docker Inc called Docker hub. We saw the features of the Docker hub and how to create a Docker hub repository. We hope that you will now be able to get build your first repository in the Docker hub registry very easily.

If you have any queries or suggestions, please mention them in the comments. We will heve our experts get back to you as soon as possible.

Recommened Articles –

  1. What is Docker?
  2. What are Docker Images?
  3. How to Pull Docker Images?
  4. How to Build Docker Images?

Happy Learning!

Leave a Reply