Docker - Download an image using the docker pull command

This assumes you have installed Docker on Linux and Docker is running.

A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).

 

There are various ways to pull down an image:

  • Using the docker pull command (as-is image as-is is pulled down)
  • Using the docker run command (as-is image is pulled down and container is created/started)
  • Using the docker build command (image can be customized)
  • Using the docker stack deploy command (Docker Compose)

 

Before pulling down an image, you'll want to use the docker images command to return the list of images that have allready been pulled down, like this.

docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
foo                 latest              105b54dc64f1        32 hours ago        196.7 MB

 

Then, use the docker search command to find the image you want to pull down.

The docker pull command followed by the name of the image pulls down the image. In this example, the "bar" image will be pulled down.

docker pull bar

 

By default, the latest version of the image will be pulled down. Or, you can explicity include latest.

docker pull bar:latest

 

Or you can specify a version.

docker pull bar:0.1.2

 

And you can optionally specify the registry that contains the image.

docker pull registry.example.com/bar:0.1.2

 

Something like this should be displayed.

Unable to find image 'bar:latest' locally
Trying to pull repository docker.io/library/bar ...
latest: Pulling from docker.io/library/bar
xxxxxxxxxxxxxx: Pull complete
xxxxxxxxxxxxxx: Pull complete
xxxxxxxxxxxxxx: Pull complete
Digest: sha256:xxxxxxxxxxxxxxxxxxxxxxx
...

 

Reissuing the docker images command should now show that the latest bar image has been pulled down.

docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
foo                 latest              105b54dc64f1        32 hours ago        196.7 MB
bar                 latest              95ga44bc5582        2 weeks ago         967 B

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter b35d9 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |