We can consider Docker Hub as a service from Docker for locating and distributing containers for each image within the specified team. It is the most comprehensive repository of container images, with an order of all content sources, including open-source projects, developing the sharing of the application source code, and community developers using containers.
What Is Docker Hub?
Docker Hub is a Docker Registry, a cloud-hosted version, open-source, scalable server-side application, and stateless. It can manage the sharing and storage of Docker images. Using Docker, developers can access it as public and create their own private repositories space and automate application build custom functions, work-groups, and webhooks.
For instance, a DevOps-trained developer can download the official MongoDBSQL document-oriented database system container image from Docker Hub to practice on an application deployed within the containers.
Docker Hub Features
- Repositories: It contains the Push and Pull process for container images.
- Teams and Organizations: It allows access to developer/user to private repositories of container images.
- Docker Official Images: It Pulls and uses high-standard quality container images rendered by Docker.
- Docker Verified Publisher Images: It Pulls and uses high-standard quality container images rendered by outside vendors.
- Builds: It provides the mechanisms that automatically formulate container images from Bitbucket and GitHub and push them to Docker Hub.
- Webhooks: It triggers certain actions after a successful push to a container to combine Docker Hub with additional services.
- Docker implements a Docker Hub CLI tool that is presently experimental and an API (Micro-service) that enables you to communicate with Docker Hub. You can browse the Docker Hub API documentation to search for the braced endpoints.
Creating First Repository
Below are the following steps that define the step-by-step features for creating the first repository:
Step 1: Create Your Docker ID
- To share images on Docker Hub, a Docker ID provides you access and entry to Docker Hub repositories and allows you to search images from the Docker community and confirmed publishers.
Step 2: Create Your First Repository
- To generate a repository:
- Please Sign in to Docker Hub.
- Click on Create a Repository option on the Docker Hub welcome page.
- Name it <your-username>/my-testprivate-repo.
- Set the visibility as Private as per the below screenshot.
- Click on Create option.
- And you can see your own created first repository.
Step 3: Install and Download Docker Desktop
For installing and downloading Docker Desktop to push and build a container image to Docker Hub:
- Install and Download Docker Desktop. If you want to do it in Linux, download Docker Engine.
- Then sign in to the Docker Desktop application with the help of Docker ID (as created in Step 1).
Step 4:
- Push and Build a container image to the Docker Hub from your system.
- Create a Dockerfile and define it into your application as per the below command:
# syntax=docker/dockerfile:1
FROM yourbox
CMD echo "Hello world! It is the first Docker image."
- Run docker build -t <your_username>/my-private-repo to create your Docker image.
- Run this below docker:
run <your_username>/my-private-repo and test your Docker image locally.
- Please Run docker push <your_username>/my-private-repo to push your created Docker image to Docker Hub.
- After the above repository in Docker Hub syntax, it displays and runs successfully and generates a new tag under Tags.
- Now sign up for a Docker account to create your first repository.
- Now Built a Docker container image on your system
- And Push it successfully to Docker Hub
Exploring the Images
In Docker, we can search for images by using the docker search command, which helps and gets the search images from the public docker repository.
In the docker search command, we have the TERM keyword to locate and find the images that match the specified TERM.
docker search TERM
For instance, the following command will locate the images from the BusyBox
images.
docker search busybox
After running the above command as per the below screenshot, it will show the output with the detailed description and number of stars and the image's status as official or automated.
Docker Search: Examples
For Docker search help, enter the below command:
docker search --help
Search for the Term 'ubuntu':
docker search ubuntu
Search for the Ubuntu Image; it will display official images:
docker search --filter=is-official=true ubuntu
Output:
Downloading an Image
For downloading an image using Docker images from ASG Docker Registry (registry.asg.com):
ASG allows online Docker registry (registry.asg.com) and downloads the Docker images into your local registry as per the below steps:
- Click on Login to the online Docker registry.
- Run the below command and enter the login credentials:
docker login registry.asg.com
For instance:
$ docker login registry.asg.com
Username: your_org_name
Password: *****
Login Succeeded
Another approach is using the docker image pull method to pull all the images or repositories from a registry using the below command.
docker image pull [OPTIONS] NAME[:TAG|@DIGEST]
Name, shorthand |
Default |
Description |
--all-tags , -a |
It will download all tagged images in the repository. |
|
--disable-content-trust |
true |
Skip image verification. |
--platform |
API 1.32+ Set platform if the server is multi-platform capable. |
|
--quiet , -q |
Suppress verbose output. |
Creating an Image
For creating a Docker image, we need to start with the existing image. We can customize it and change it as per the scenario and create a new image.
How Does It Work?
- First, we need to instantiate the primary base image or define the docker to create a container from within the image.
- Then, we need to install Docker.
- Next, we need to get a base image such as webdevops/php-nginx, which we can locate in the Docker Hub repository — in order to “pull” it, we need to have a Docker Hub ID. If it's not created, we can refer to https://hub.docker.com and build a free account.
- Then go to the command line where we have Docker installed and login to the Docker Hub:
Syntax:
- Here, we start with the base image and refer to Docker to start a container.
- The docker image provides the webdevops/php-dev with an apache daemon that runs on ports 80 and 443.
- Here, -dP flag defines gets and sets the container, and it runs in the background.
- The container runs successfully, as shown in the output image below.
Pushing an Image
For pushing an image or a repository, below is the syntax and steps we need to follow:
Using docker image push, we can share the images from the Docker Hub.
Push a New Image to a Registry
Firstly, store the latest image by getting the container ID and committing it to its original name.
As per the standard, we need to follow only a-z0-9-_. allowed when selecting images:
Syntax
- $ docker container commit c16378f943fe rhel-httpd:latest
In this command, we provide port 5000 with hostname and IP address details
- $ docker image tag rhel-httpd:latest registry-host:5000/myadmin/rhel-httpd:latest
$ docker image push registry-host:5000/myadmin/rhel-httpd:latest
Below is the command to check how it performs after running:
Push All Tags of an Image
The -a (or --all-tags) option to push all tags of a local image should be the preferred option.
The following example creates multiple tags for an image and pushes all those tags to Docker Hub.
- docker image tag myimage registry-host:5000/testname/testimage:latest
- docker image tag myimage registry-host:5000/testname/testimage:v1.0.1
- docker image tag myimage registry-host:5000/testname/testimage:v1.0
- docker image tag myimage registry-host:5000/testname/testimage:v1
What Are Docker Certified Images?
- Docker Official Images are a set of Docker repositories organized systematically, published, and hosted on Docker Hub. They are maintained to enable the necessary base OS (operating system) repositories (ubuntu, centos, etc.) that support defining the initial point for the users.
- It enables the drop-in resolutions for defining the data stores, runtimes, and other services within the programming languages as per the process of Platform as a Service (PAAS).
- It provides various types of security updates utilized in a timely defined manner.
- We can locate the Docker Official Images from Docker Hub.
We can create Docker Certified image using the GitHub pull from the below GitHub repositories:
- docker-library/official-images
- docker-library/docs
Popular Images on DockerHub
In DockerHub, we can integrate third-party images and add and configure them in public repositories to make them more interactive and productive for your product.
Here is the list of a popular list of images:
Product |
Docker Hub Pulls |
Docker Hub Stars |
G2 Crowd Star Rating |
Satisfaction Score |
Market Presence |
Wordpress |
10,000,000 |
4169 |
4.3 |
99 |
80 |
Ubuntu |
10,000,000 |
233 |
4.5 |
94 |
50 |
MySQL |
10,000,000 |
225 |
4.4 |
93 |
75 |
MongoDB |
10,000,000 |
168 |
4.4 |
90 |
52 |
Mariadb |
10,000,000 |
37 |
4.6 |
90 |
34 |
Arangodb |
1,000,000 |
22 |
4.9 |
90 |
23 |
Ruby on Rails |
1,000,000 |
52 |
4.5 |
84 |
30 |
PostgreSQL |
10,000,000 |
128 |
4.4 |
82 |
36 |
Django |
1,000,000 |
59 |
4.6 |
79 |
25 |
Redis |
10,000,000 |
70 |
4.4 |
76 |
32 |
Memcached |
10,000,000 |
11 |
4.6 |
76 |
18 |
Centos |
10,000,000 |
68 |
4.5 |
75 |
32 |
Fedora |
10,000,000 |
44 |
4.5 |
72 |
54 |
Nginx |
10,000,000 |
31 |
4.8 |
72 |
36 |
RethinkDB |
5,000,000 |
13 |
4.4 |
67 |
20 |
SonarQube |
5,000,000 |
10 |
4.6 |
66 |
24 |
Sentry |
5,000,000 |
29 |
4.3 |
62 |
26 |
Jenkins |
10,000,000 |
161 |
4.2 |
52 |
31 |
Owncloud |
10,000,000 |
58 |
4 |
50 |
30 |
Tomcat |
10,000,000 |
21 |
4.4 |
49 |
35 |
Joomla |
1,000,000 |
111 |
3.9 |
48 |
28 |
Apache Server |
10,000,000 |
23 |
4.4 |
48 |
45 |
Neo4J |
5,000,000 |
30 |
4.4 |
46 |
32 |
Elasticsearch |
10,000,000 |
28 |
4.6 |
44 |
32 |
Apache Maven |
10,000,000 |
87 |
4.1 |
42 |
36 |
Docker HUB Webhooks
The best use of webhooks is defining the action and getting the response as a push event in the repository. We can consider it a POST request sent to API-URL and can be described in Docker HUB.
For configuring Webhooks, we can use the “webhooks” tab on the Docker Hub repository as shown below:
Create Webhooks
- Define a name for the webhooks.
- Give a destination webhook URL link where webhook POST requests will be delivered:
Conclusion
We hope this article helped you understand Docker Hub. In this article, we discussed the concept of various repositories and their different types, along with examples that will be helpful to professional developers from Java and .net backgrounds, application architectures, cloud specialists, and other learners looking for information on Docker Hub with the containers.
Learn more about Docker Hub with our PGP DevOps training course, designed in collaboration with Caltech CTME. It is a professional development option that'll square your skills with industry standards. Our cutting-edge Blended Learning combines live online DevOps certification classes with interactive labs that'll give you hands-on experience. Enroll today!