To get started with Docker Hub, first, sign up for a Docker Hub account and create a Docker Hub first repository. After that, to play with Docker images and containers, download the Docker on your system. Next, search for an image from the Docker hub, download it, and execute it in the container. Users can also upload the user-programmed image on Docker Hub.
Let’s first understand what Docker Hub is. Then, dive into the steps to get started with Docker Hub.
What is Docker Hub?
The Docker Hub is an open-source cloud-based Docker registry or service that is utilized to manage the container images. It is the world’s largest cloud-based service that hosts thousands of images. It can store and manage the Docker images in repositories with image names and tags. It offers basic features free of cost for personal use and users can publish unlimited images in public repositories. To unlock advanced features such as managing teams or organizations on Docker hub, to create and run unlimited private registries, it offers different reasonable subscription plans.
Features of Docker Hub Server Application
Some key features of the Docker Hub service are listed below:
- Repositories: It offers repositories that are used to manage the container images.
- Official and Verified Images: It provides thousands of official images and images published by verified vendors.
- Teams and Organizations: It allows us to run and manage teams. It gives developers access to the private repository within the organization.
- Webhooks: It triggers actions after container images are successfully pushed to a repository. It set up Docker Hub to work with other services
- Automatic Build: The user can automatically build docker images from GitHub and Bitbucket and then push these images to the Docker Hub repository.
- Docker CLI: Docker Hub can also be accessible and managed through Docker CLI.
How to Get Started With Docker Hub
The Docker development environment is usually required to manage the container snapshots on cloud storage. For this purpose, users can use two different types of registry: public and private registry. Users can also create their personal private registry. The Docker Hub is Docker’s official cloud-based service or registry to publish and manage Docker images.
To get started with Docker Hub, go through the below-provided steps:
- Sign Up for a Docker Hub Account
- Create a Docker Repository
- Install the Docker Desktop Application
- Search Docker Image From Docker Hub
- Pull and Run Image From Docker Hub
- Publish the Image on Docker Hub
Sign Up for a Docker Hub Account
To sign up for the Docker Hub account, go through the following instructions.
Step 1: Sign Up For Docker Hub
First, navigate to the official Docker Hub website and hit the below pointed “Sign up” option:
Provide the essential credentials to create a new Docker Hub account. For this purpose, first, provide the email to register to the Docker Hub account. Then, set the user credentials for the Docker Hub account. After that, hit the “Sign up” button:
This may ask you for human verification.
Step 2: Log In to Docker Hub Account
After that, you will land on the Docker Hub login page. Provide the Docker Hub username and hit the “Continue” button:
Now, provide the Docker Hub password and press “Continue”:
Step 3: Choose Your Plan
From the next step, choose your plan to use the Docker Hub account. For personal use and local development, it is recommended to use a “Personal” plan. However, users can also choose the plan according to their need. To freely unlock the Docker Hub basic features, we have clicked on the “Continue with Personal” button and choose the “Personal” plan:
Step 4: Email Verification
In the next step, the Docker Hub will ask you to verify the provided email address. For this purpose, log in to your email account and verify the Docker Hub:
Here, we have successfully verified and created the new Docker Hub account:
Create a Docker Repository
The Docker Hub repository is used to manage the container images with names or tags. The Docker Hub repositories are of two types: private repositories that are unlocked by the Docker Hub’s “Pro” plan and Public repositories available for free of cost in the “Personal” plan. To get started with the Docker Hub repository, go through the below procedure:
First, navigate to the “Repositories” menu, and select the namespace from the namespace drop menu. Here, we have only the “handsoncloud” namespace which is the Docker Hub user account. After that, click on the “Create repository” button to create a new repository:
Next, set the name and description for the Docker Hub repository, and choose the “Public” radio button to create a public repository. After that, press the “Create” button. For demonstration, we have created “html” public repository:
Here, we have effectively created the “html” Docker Hub repository to manage HTML images:
Install Docker or Docker Desktop Application
The Docker desktop application is a GUI version of Docker and provides an easy-to-use UI to manage and operate Docker components. To containerize the user application, the user first needs to generate the container image. To create the container image and to run the Docker container, first in the “Docker” on Linux and Docker Desktop application on Windows and Mac OS. After that, the Docker application can connect with a Docker Hub account to manage and publish container images on the cloud service.
- To download and install the Docker Desktop application either on Windows, Linux, or Mac, go through our “Install Docker Desktop Application” article.
- To install the Docker application on Ubuntu, follow the “Install and Use Docker on Ubuntu” article.
Search Docker Image From Docker Hub
To search the Docker published images from Docker Hub, users can search it either using the Docker Hub server-side application or through Docker CLI.
Search Docker Image From Docker Hub
To search images from Docker Hub, log in to the Docker Hub account as done in the first step. After that, navigate to the “Explore” menu, search for the name of the image in the Docker Hub search bar, and choose the image from the search results:
Here, you can see we have successfully searched the “nginx” official Docker image. Click on the image to get more information about image:
From the “nginx” repository, the user can access the “nginx” image of different versions from the “Tags” menu. Users can download the latest image by executing the below-highlighted command in the terminal:
Search Docker Image From Docker CLI
To search Docker image from Docker Hub using Docker CLI, the user first needs to log in to the Docker Hub account from Docker CLI. For this purpose, simply run the “docker login” command:
docker login
This will ask you to type in the username and password of the Docker Hub account. Provide the required credentials and hit Enter:
After successfully logging in to Docker Hub, search the Docker image using the “docker search <image name>” command:
docker search nginx
Pull and Run Image From Docker Hub
In the next step, pull or download the searched or required image from the Docker Hub account. For this purpose, utilize the “docker pull <image name>:<version>” command:
docker pull nginx
This will automatically download the nginx latest image from Docker Hub:
In order to execute the pulled Docker image inside the container, utilize the “docker run -p <host port>:<container port> <image-name>” command:
docker run -p 80:80 --name demo-cont nginx
In the above command “-p” will expose the container port on the host system and “–name” sets the container name:
For verification, open the browser, navigate to “http://localhost:80” and check if the image is executing in the container. Here, you can see we have effectively downloaded and executed the “nginx” image:
Publish the Image on Docker Hub
The Docker Hub cloud service is mainly used to publish and manage the Docker images in Docker Hub repositories. To publish the Docker image in the Docker Hub repository, go through the following instructions.
Step 1: Create an Image
To dockerize the user application, the user first needs to create the Docker image. To create your first Docker image, follow our detailed guide on “Create Docker Image”. To list down the Docker images, utilize the “docker images” command:
docker images
Here, currently, we have four Docker images. For demonstration, we will push “html-img” in Docker Hub’s “html” repository:
Step 2: Tag the Image
To push the image, the user first needs to tag the image with “Docker Hub user account” and “Repository or Image name”. To tag the docker image, utilize the “docker tag <image name> <Docker Hub username>/<Repository or Image name>:<Image version>” command:
docker tag html-img handsoncloud/html:1.0
For confirmation, again list down the Docker images:
docker images
Here, we have tagged the “html-img” as “handsoncloud/html:1.0” image:
Step 3: Publish the Image
Now, push the image to the Docker Hub repository using the “docker push <tagged image>” command:
docker push handsoncloud/html:1.0
Step 4: Verification
For verification, open the Docker Hub account, navigate the “html” repository, and check if the image is pushed or not. The output shows that we have effectively pushed or published the image on Docker Hub:
To check how this image will be viewed by other users on Docker Hub, hit the “Public View” button:
From the tags, click on the image and Docker Hub will provide the command to download the published image:
Here we go! We have demonstrated the steps to get started with Docker Hub from scratch.
Conclusion
To get started with Docker Hub, the user first needs to create a Docker Hub account from Docker Hub’s official website. After that, log in to the account, choose your subscription plan, and create your first repository. Docker Hub also provides thousands of images. So, to search images from Docker Hub, the user can use the “docker search <image-name>” command. In order to download or pull the image from Docker Hub, run the “docker pull <image name>” command. To publish or manage any container image on Docker Hub, first, tag the image with the Docker Hub username and then push the image to Docker Hub through the “docker push <tagged image>” command. This write-up has discussed the steps to get started with Docker Hub.