Open In App

What is Docker Hub?

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 Features 

Advantages of Docker Hub

Creating First Repository  in Docker Hub Using GUI

Step 1: We must open Docker Hub first, then select 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. 

 

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>.

 

 

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:

# 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.

 

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

 

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

 

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

 

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

# docker images

 


Article Tags :