Docker

How to Update Docker Images to the Latest Version

Docker images are considered as a building block of Docker and referred to as a template or framework. These images are utilized to build containers and also guide them on how to build, ship, and deploy projects in containers. More specifically, Docker Hub, the official Docker registry provides thousands of images in different versions for developer support. The Docker developer upgrades and downgrades the application and image version with the help of the Docker Hub registry.

This write-up will explain how to update images in Docker to the latest version.

How to Update Docker Images to the Latest Version?

To update the images to the newest or latest version in Docker, utilize the Docker Hub official registry. For this purpose, first, log in to the Docker Hub registry and pull the image of your desired version or the latest version. For the demonstration, check out the provided instructions.

Step 1: Log in to Docker Hub
To log in to Docker, first, open up your favorite Windows terminal and run the “docker login” command. This command prompts you to enter the user-name and password of your Docker Hub account:

> docker login

We have already logged in to Docker Hub. Therefore, we are not prompted to enter login credentials:

Step 2: Pull Image With the Version
Next, pull any version of an image from Docker Hub. For instance, we have pulled “mysql:5.7” using the provided command:

> docker pull mysql:5.7

For confirmation, list the images and check if the image has been pulled or not:

> docker images

Step 3: Inspect Image
Inspect the image to check the version of the image. For this purpose, utilize the “docker inspect” command along with the image id:

> docker inspect be16cf2d832a

From the output, you can see we are using the “5.7” version of the “mysql” image:

Step 4: Update Image Version to Latest
In order to update the image to the latest version, pull the image using the “<image-name>:latest” syntax as follows:

> docker pull mysql:latest

Again, list down the images and check if the image of the latest version has been pulled. The “Tag” column is showing the detail of the image version:

> docker images

However, you can inspect the image using its id and verify if the image has been updated to the latest version or not:

> docker inspect 05b458cc32b9

Here, you can see, our images have been upgraded to the “8.0” version:

Users can navigate the Docker Hub repository from the browser and check the images and available versions:

This is all about how to update the Docker images to the latest version.

Conclusion

Thousands of images are published on the Docker Hub registry. Users can easily access the image of any version from the Docker Hub official registry. In order to update the image to the latest version, first, log in to the Docker Hub account. Then, utilize the “docker pull <image:latest>” command. This write-up has demonstrated how to update the Docker image to the latest version.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.