Watch a specific repository and filter by tag
In this step, you will learn how to watch a specific Docker repository and filter by tag when pulling images. Docker images often have different versions or variations identified by tags. Specifying a tag allows you to pull a particular version of an image.
In the previous step, we pulled the hello-world
image with the default latest
tag. Now, let's pull a different image, for example, the ubuntu
image, and specify a particular tag. We will pull the 20.04
tag, which corresponds to the Ubuntu 20.04 LTS release.
docker pull ubuntu:20.04
You will see output indicating the download progress for the specified Ubuntu image tag.
20.04: Pulling from library/ubuntu
...
Status: Downloaded newer image for ubuntu:20.04
docker.io/library/ubuntu:20.04
This command tells Docker to download the ubuntu
image specifically with the 20.04
tag. If you don't specify a tag, Docker defaults to latest
.
Now, let's list your local images again to see the newly downloaded ubuntu:20.04
image.
docker images
You should now see both hello-world:latest
and ubuntu:20.04
in the list.
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest ... ... ...
ubuntu 20.04 ... ... ...
This shows that you have successfully pulled a specific version of the ubuntu
image by specifying its tag.
You can also pull other tags of the same image. For instance, let's pull the 18.04
tag of the ubuntu
image.
docker pull ubuntu:18.04
Again, you will see the download progress.
18.04: Pulling from library/ubuntu
...
Status: Downloaded newer image for ubuntu:18.04
docker.io/library/ubuntu:18.04
Listing your images one more time will show all three images you've pulled.
docker images
The output will now include ubuntu:18.04
.
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest ... ... ...
ubuntu 20.04 ... ... ...
ubuntu 18.04 ... ... ...
This demonstrates how you can use tags to manage different versions of the same image on your local machine.