Open In App

What is Docker Hub?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

Pre-requisites: Docker

Docker Hub is a repository service and it is a cloud-based service where people push their Docker Container Images and also pull the Docker Container Images from the Docker Hub anytime or anywhere via the internet. It provides features such as you can push your images as private or public. Mainly DevOps team uses the Docker Hub. It is an open-source tool and freely available for all operating systems. It is like storage where we store the images and pull the images when it is required. When a person wants to push/pull images from the Docker Hub they must have a basic knowledge of Docker. Let us discuss the requirements of the Docker tool.

Docker is a tool nowadays enterprises adopting rapidly day by day. When a Developer team wants to share the project with all dependencies for testing then the developer can push their code on Docker Hub with all dependencies. Firstly create the Images and push the Image on Docker Hub. After that, the testing team will pull the same image from the Docker Hub eliminating the need for any type of file, software, or plugins for running the Image because the Developer team shares the image with all dependencies.

Docker Hub Registry

 

Docker Hub Features 

  • Storage, management, and sharing of images with others are made simple via Docker Hub.
  • Docker Hub runs the necessary security checks on our images and generates a full report on any security flaws.
  • Docker Hub can automate the processes like Continuous deployment and Continuous testing by triggering the Webhooks when the new image is pushed into Docker Hub. 
  • With the help of Docker Hub, we can manage the permission for the users, teams, and organizations. 
  • We can integrate Docker Hub into our tools like GitHub, Jenkins which makes workflows easy 

Advantages of Docker Hub

  • Docker Container Images are light in weight.
  •  We can push the images within a minute and with help of a command. 
  • It is a secure method and also provides a feature like pushing the private image or public image. 
  • Docker hub plays a very important role in industries as it becomes more popular day by day and it acts as a bridge between the developer team and the testing team.
  •  If a person wants to share their code, software any type of file for public use, you can just make the images public on the docker hub.

Creating First Repository  in Docker Hub Using GUI

Step 1: We must open Docker Hub first, then select Create Repository.

Create repository

 

Step 2: After that, we will be taken to a screen for configuring the repository, where we must choose the namespace, repository name, and optional description. In the visibility area, as indicated in the picture, there are two options: Public and Private. We can choose any of them depending on the type of organization you are in. If you chose Public, everyone will be able to push-pull and use the image because it will be accessible to everyone. If you select the private option, only those with access to that image can view and utilize it. it. 

Configure repository

 

Step 3: At finally repository is created with the help of the Docker Commands we can push or pull the image.

docker push <your-username>/my-testprivate-repo>.
Public Repository

 

 

How To Push or Pull Images from Docker Hub? 

To get started with Docker Hub you should be able to get familiar with the below two commands:

1. Push Command

This command as the name suggests itself is used to pushing a docker image onto the docker hub.

Implementation 

Follow this example to get an idea of the push command:

  • Open Docker in your system.
  • Locate the Images that you want to push using the below command:
# docker images
Docker images

 

The above command will list all the images on your system.

Step 1: Go to the browser and search hub.docker.com.

Step 2: Sign up on the docker hub if you do not have a docker hub account, after login on to docker hub.

Step 3: Back to the docker terminal and execute the below command:

# docker login

Step 4: Then give your credential and type in your docker hub username or password.

  • username
  • password
Docker login

 

Step 5: After that hit the Enter key you will see login success on your screen.

 

Step 7: Then type the tag images name, docker hub username, and give the name it appears on the docker hub using the below command:

 # docker tag geeksforgeek mdahtisham/geeksimage
          geeksforgeek - Image name
          mdahtisham - Docker hub username
          geeksimage - With this name Image will appear on the docker hub

Step 8: Now push your image using the below command:

# docker push mdahtisham/geeksimage
Docker push

 

Note:Below you can see the Docker Image successfully pushed on the docker hub: mdahtisham/geeksimage

Docker hub Repository

 

2. Pull Command

The pull command is used to get an image from the Docker Hub.

Implementation:

Follow the example to get an overview of the pull command in Docker:

Step 1: Now you can search the image using the below command in docker as follows:

# docker search imagename

One can see all images on your screen if available images with this name.One can also pull the images if one knows the exact name

Step 2: Now pull the image see the below command.

# docker pull mdahtisham/geeksimage
   mdahtisham - Docker Hub username
   geeksimage - With this name Image will appear on the docker hub
Docker pull

 

Step 3: Now check for the pulled image using the below command as follows:

# docker images
Docker images

 



Last Updated : 25 Apr, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads