How to Download Docker Image with docker pull Command
The docker pull command is very simple and easy to use command line tool to download Docker images. This Docker tutorial explains how to pull docker images from the Docker repository using the docker pull command.
Before downloading images, you need to know the name of the image. You can find images using the docker search command:
docker search NAME
Once you figure out which image you would like to work with, you can run the docker pull command and download the image:
docker pull NAME
For example, following command will download the Ubuntu image to the local system:
docker pull ubuntu
Using tags, we can download a specific version of image to our local system (you can find available tags from the docker hub). For example, if you use the latest tag, docker pull command will download the latest image:
docker pull ubuntu:latest
docker pull ubuntu:19.04
If you don’t add a tag, the tag latest is implied.
The latest tag does not necessarily mean it will download the most recent version of the image. When the latest tag is used, docker daemon will download the image tagged as latest. For example, ubuntu:latest tag points to the "latest LTS" release rather than the most recent release. The download will fail If the remote repository does not have an image with the latest tag.
If the -a flag is used, it will Download all tagged images in the repository.
docker pull -a hello-world
To list available images on your local system, run the docker images command:
Note that, the docker pull is done automatically when you do a docker run command and if the image is not already present in the local system. But it is a good practice to download the image manually before starting a new container with docker run command.
Next, we are going to learn how to Start Docker Containers with docker run Command.