how to pull a docker image

We are going to work with Docker images and how to pull a docker image would be our first step. A Docker image consists of multiple layers. When we pull a Docker image, it actually pulls all the layers associated with it. The Docker images can reuse those layers if you want to pull another image with a different tag. When we use the docker pull command, it downloads the image locally on your system. After that image is pulled, you can run it to fire up a container.

If you haven’t installed Docker and don’t know much about it, please go through the following quick guides. You must have an idea about all the important terms used in this article. 

So, are you ready?

Let’s explore the docker pull command and learn how to pull a Docker image. 

1. The docker pull Command

It’s as simple as:

docker pull nginx

It will pull the NGINX image from the Docker Hub locally on your Linux machine. NGINX is a high-performance load balancer and a web server. We can use multiple options in the docker pull command but first, we need to learn the basics. The actual docker pull command is like this:

docker pull image_name:tag

If you don’t give an image any tag while pulling it, it will use the “latest” as the default tag like in the example given below.

docker pull nginx

Here, I am pulling an NGINX image. By default, it is downloading the image with the “latest” tag. 

To confirm the image download, execute the following command:

docker images

You can see the NGINX image is downloaded with an image ID and a tag.

nginx docker image with latest tag

So, whether you run: 

docker pull nginx


docker pull nginx:latest

It will download the same image with the latest tag. However, if the tag different, you have to specify it every time in the docker pull command.

2. What is Docker Image Tag?

A Docker Image tag tells us useful information about a specific image. It can be the image version or variant. In order to better understand the image tagging, log in to the Docker Hub and search for Nginx. You’ll find hundreds of images with different tags. Each image will have its own pull command that you’ll find against its tag. Copy the docker pull command with its tag and that specific image will be downloaded.

search nginx image tags in docker hub

Let’s try another NGINX image with any other tag. I am trying out the following image that is pulled with the following command:

docker pull nginx:perl

During the pull, if a certain image layer has been pulled already, it means it already exists. The Docker Engine pulls the other layers saving disk space and bandwidth. That’s the most beautiful part of pulling images.

Now there should be two NGINX images with 2 different tags.

  • latest
  • perl

Is that correct?

Let’s confirm with the docker images command.

nginx image with different tags

I hope now you have an idea about image tags. Search for some other images, change their tags and repeat the Docker pull image drill.

3. How to Pull Docker Image with Digest?

Whenever an image is pulled, you’ll find the Digest of that image at the end. It starts with the SHA256 hash of the image’s JSON configuration object. For instance, this is the Digest of the Ubuntu latest Docker image.


You can find each image’s digest in Docker Hub. So, there are basically three columns for any image.

  1. Digest
  2. OS/Arch
  3. Size

The digest is different if the operating system has a different architecture. Pulling an image with the digest allows you to pull a fixed version of an image. If you don’t want your images to be updated to the newer versions, use the digest method for pulling images.

find docker image digest

Click on the digest and you’ll get the full hash to pull the image.

So, I have copied the following hash to download the Ubuntu image using the digest.


Run the following command to pull the Docker image using the digest.

docker pull [email protected]:376209074d481dca0a9cf4282710cd30a9e7ff402dea8261acdaaf57a18971dd

Write the username ubuntu at the start of the hash otherwise, it will ask for the Docker login credentials.

use digest to pull the docker image

Finally, that’s how we pull the images with the digest from the Docker Hub. Run the docker images command to verify the pull.

4. Pulling Docker Images with all tags

A Docker image can have hundreds of tags. We can pull all those images with a single command. Let’s try out and pull all the images of Alpine Linux. Alpine Linux is a security-oriented and lightweight Linux distribution.

Here is the command:

docker pull --all-tags alpine

It has started pulling all the images of Alpine Linux. You can see the Digest of each image. This command will take some time to complete.

pulling docker image with all tags

Run the docker images command and see the magic.

how to pull a docker image with all tags

Alpine Linux is a lightweight distribution with a size of only 5MBs. Using the –all -tags option has downloaded all the images stored on the Docker Hub. You can see most of the Alpine images have a version as a tag. Therefore, we can use tags for image versioning as well.

5. Quick Summary

Finally, I hope you have a better idea now to pull a Docker image. I would strongly recommend going through each command and run it. Also, change the images, try different tags and see the output.

If you have any questions or issues, feel free to let me know in the comments.

Happy Docking!!!

Leave a Comment

Recent Posts

how to stop a docker container
How to Run a Docker Container
How to Push a Docker Image to a Private Repository
How to push a docker image
How to Tag a Docker Image
Software Spice
Share via
Copy link
Powered by Social Snap