Docker

Introduction to Docker Pull

Hello. In this tutorial, we will talk about Docker and a brief introduction to Docker pull command.

1. What is Docker?

In the present world, Docker is an important term –

  • Often used in CI/CD platform that packages and runs the application with its dependencies inside a container
  • Is a standard for Linux Containers
  • A Container is a runtime that runs under any Linux kernel and provides a private machine-like space under Linux

1.1 What is Docker used for?

It is used for –

  • For environment replication, while the code runs locally on the machine
  • For numerous deployment phases i.e. Dev/Test/QA
  • For version control and distributing the application’s OS within a team

1.2 Basic Docker terminology?

  • Image: Representation of Docker container i.e. a JAR or WAR file in Java
  • Container: Runtime of Docker i.e. a deployed and running Docker image. For example, an executable Spring Boot jar
  • Engine: The code that manages, creates, and runs the Docker containers
  • Hub: A public developers registry to distribute their code
  • Repository: A collection of Docker related images i.e. different versions of the same application

1.3 Setting up Docker

If someone needs to go through the Docker installation, please watch this video.

2. Introduction to Docker Pull

A docker pull command is used to download a docker image from the repository onto the host system from the public or private repository. It is represented by the code syntax –

Command syntax

docker pull IMAGE_NAME:TAG_NAME

The above command supports different flags i.e. –

  • -all-tags: Used to download all the images with different tags in the repository
  • -disable-content-trust: Skip image verification before sleeping
  • -platform: Set the platform
  • -quiet: Pull images silently with no output
  • -help: To know more about the command

2.1 How Pull Command works in Docker?

The docker pull command first checks locally for the image and if the image does not exist locally then the docker daemon connects to the public repository i.e. hub.docker.com for downloading the mentioned docker image onto the host system. If there is a private repository mentioned in the daemon.json file then the image is pulled from that private repository but not public. By default for any image, the latest tag is used. If any tag is given in the pull then that tag is downloaded from the docker repository.

2.2 Pull a Repository with all Available Tags

To pull all tags for a docker image we will use the --all-tags flag. Let us understand this with the help of a code snippet and an example.

Command syntax

docker pull –all-tags IMAGE_NAME

In the below picture the command will download all available tags for the alpine image using the following command – docker pull --all-tags alpine. If everything goes well use the docker images command to list the downloaded images.

Fig 1. docker pull command

In case an image has to be pulled from any different or private repository just specify the part of that repository while pulling the image from that registry. For example –

Command syntax

docker pull REGISTRY_PATH/IMAGE_NAME

2.3 Pull the Image without any verbose output

We will use the --quite flag to download a docker image silently. Let us understand this with the help of a code snippet and an example.

Command syntax

docker pull --quiet IMAGE_NAME:latest

In the below picture the command with the download the nginx image with the latest tag silently. If everything goes well use the docker images command to list the downloaded image.

Fig. 2: docker pull command with quiet flag

2.4 Benefits of docker pull command

Docker pull command is helpful in –

  • Downloading images from any registry i.e. public or private
  • Downloading the complete repo with the help of --all-tags flag
  • Downloading unsigned images as well
  • Downloading images silently with the help of --quiet flag

That is all for this tutorial and I hope the article served you with whatever you were looking for. Happy Learning and do not forget to share! Happy learning and do not forget to share!

3. Summary

In this tutorial, we learned about Docker and the docker pull command. You can also download the commands used in this tutorial from the Downloads section.

4. Download the Project

This was a tutorial on learning Docker and playing around with the docker pull command.

Download
You can download the full source code of this example here: Introduction to Docker Pull

Yatin

An experience full-stack engineer well versed with Core Java, Spring/Springboot, MVC, Security, AOP, Frontend (Angular & React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button