Searching and pulling Docker Images from Dockerhub

The official Docker registry contains a lot of pre-built images and publicly available customized images that are very useful and can be easily pulled by users on their local machine and used as base images for their projects. In fact, you can also build your own customized docker image using one of those publicly available docker images and push it back either in a public or private mode.

In this article, we will discuss how to search for a docker image using the search command through the command line interface. We will also see how to filter the search results based on certain parameters. After that, we will see how to pull those images and list all the pulled images in your local machine using the docker pull and list commands.

Setting Up Docker Hub Access

To start building a container or an image, we need to specify a base image in our dockerfile so that on top of that base image, we can build our own customized image layers and install packages, libraries and much more. These base images are available in the official docker registry which is called Docker Hub.

While you can search and pull public images without an account, to access private repositories, you need to have an account created on Docker Hub and be logged in through the command line using the docker login command:

sudo docker login

Searching Docker Images

You can search for base images using the docker search command with the following syntax:

sudo docker search <search-term>

In place of the term, you need to enter the name or a keyword related to that image to generate a list of similar images available on Docker Hub.

Search Examples

To search for an ubuntu image:

sudo docker search ubuntu

To search for a busybox image:

sudo docker search busybox

Understanding Search Results

The output of the search command contains several columns:

Field Description
NAME The name of the image repository
DESCRIPTION Short description about the image
STARS Number of stars given by users (popularity metric)
OFFICIAL Whether the image is from Docker's official repository
AUTOMATED Whether the image builds automatically from source code changes

Filtering Search Results

You can filter search results using the --filter option to narrow down your results based on specific criteria.

Filter by Stars

To find images with a minimum number of stars (e.g., 30 stars):

sudo docker search --filter=stars=30 ubuntu

Filter by Automated Builds

To find only automated builds:

sudo docker search --filter=is-automated=true ubuntu

Filter by Official Images

To find only official images:

sudo docker search --filter=is-official=true ubuntu

To get help with the search command:

sudo docker search --help

Pulling Docker Images

After identifying the image you want, pull it using the docker pull command:

sudo docker pull <image-name>:<tag-name>

The tag name specifies a particular version of the image. If you don't specify a tag, Docker automatically pulls the latest tag.

Pull Examples

sudo docker pull python:3
sudo docker pull ubuntu
sudo docker pull nginx:alpine

Pulling All Tags

To pull all tagged versions of an image:

sudo docker pull --all-tags python

Listing Downloaded Images

To list all images stored locally on your machine:

sudo docker images

This command displays information about each image including repository name, tag, image ID, creation date, and size.

You can also use additional options:

sudo docker images --all          # Show all images including intermediate layers
sudo docker images --quiet        # Show only image IDs
sudo docker images --no-trunc     # Don't truncate output

Conclusion

Docker Hub provides a comprehensive registry of container images that can be easily searched and pulled for your projects. Using filtered searches helps you find the most suitable and trusted images based on popularity, official status, and automated builds. Understanding image tags ensures you get the right version for your specific requirements.

Updated on: 2026-03-17T09:01:38+05:30

641 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements