This lesson is being piloted (Beta version)

Pulling Images

Overview

Teaching: 10 min
Exercises: 5 min
Questions
  • How are images downloaded?

  • How are images distinguished?

Objectives
  • Pull images from Docker Hub image registry

  • List local images

  • Introduce image tags

Docker Hub

Much like GitHub allows for web hosting and searching for code, the Docker Hub image registry allows the same for Docker images. Hosting and building of images is free for public repositories and allows for downloading images as they are needed. Additionally, through integrations with GitHub and Bitbucket, Docker Hub repositories can be linked against Git repositories so that automated builds of Dockerfiles on Docker Hub will be triggered by pushes to repositories.

Pulling Images

To begin with we’re going to pull down the Docker image we’re going to be working in for the tutorial

docker pull matthewfeickert/intro-to-docker

and then list the images that we have available to us locally

docker images

If you have many images and want to get information on a particular one you can apply a filter, such as the repository name

docker images matthewfeickert/intro-to-docker
REPOSITORY                        TAG          IMAGE ID        CREATED        SIZE
matthewfeickert/intro-to-docker   latest       9602bb3f01a4    11 hours ago   1.54GB

or more explicitly

docker images --filter=reference="matthewfeickert/intro-to-docker"
REPOSITORY                        TAG          IMAGE ID        CREATED        SIZE
matthewfeickert/intro-to-docker   latest       9602bb3f01a4    11 hours ago   1.54GB

You can see here that there is the TAG field associated with the matthewfeickert/intro-to-docker image. Tags are way of further specifying different versions of the same image. As an example, let’s pull the bullseye release tag of the Debian image.

docker pull debian:bullseye
docker images debian
bullseye: Pulling from library/debian
<some numbers>: Pull complete
Digest: sha256:<the relevant SHA hash>
Status: Downloaded newer image for debian:bullseye
docker.io/library/debian:bullseye

REPOSITORY   TAG        IMAGE ID       CREATED        SIZE
debian       bullseye   f776cfb21b5e   5 days ago     124MB

Additionally, there might be times where the same image has different tags. For example, we can pull the bootcamp-2021 tag of the matthewfeickert/intro-to-docker image, but when we inspect it we see that it is the same image as the one we already pulled.

docker pull matthewfeickert/intro-to-docker:bootcamp-2021
docker images matthewfeickert/intro-to-docker
REPOSITORY                        TAG             IMAGE ID       CREATED        SIZE
matthewfeickert/intro-to-docker   bootcamp-2021   64708e04f3a9   11 hours ago   1.57GB
matthewfeickert/intro-to-docker   latest          64708e04f3a9   11 hours ago   1.57GB

Pulling Python

Pull the image for Python 3.9 and then list all python images along with the matthewfeickert/intro-to-docker image

Solution

docker pull python:3.9
docker images --filter=reference="matthewfeickert/intro-to-docker" --filter=reference="python"
REPOSITORY                        TAG                 IMAGE ID       CREATED         SIZE
matthewfeickert/intro-to-docker   bootcamp-2021       64708e04f3a9   11 hours ago    1.57GB
matthewfeickert/intro-to-docker   latest              64708e04f3a9   11 hours ago    1.57GB
python                            3.9                 e2d7fd224b9c   4 days ago      912MB

Key Points

  • Pull images with docker pull

  • List images with docker images

  • Image tags distinguish releases or version and are appended to the image name with a colon