Docker is a popular containerization technology that allows you to quickly create, deploy, and run applications. However, sometimes you may need to install a specific version of Docker instead of the latest version. In this article, we’ll walk you through the steps to install a specific version of Docker on CentOS.

Step 1: Install Necessary Packages

First, you need to install some necessary packages, including yum-utils, device-mapper-persistent-data, and lvm2. These packages will help you configure Docker storage drivers and LVM volumes.

You can install these packages using the following command:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

Step 2: Add Docker Repository

Next, you need to add the Docker repository. You can add the Docker repository to your CentOS system using the following command:

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Alternatively, if you’re in China, you can use the Aliyun mirror by running the following command:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

This will add the YUM repository configuration file for the Docker repository.

Step 3: Update YUM Cache

Once the Docker repository has been added to the system, you need to update the YUM cache to be able to install packages from the repository. You can update the YUM cache using the following command:

yum makecache

Step 4: Install Specific Version of Docker

Finally, you can install the specific version of Docker that you need using the following command:

yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

Where <VERSION_STRING> is the version number of the Docker version you want to install. For example, if you want to install Docker version 20.10.8, you can use the following command:

yum install docker-ce-20.10.8 docker-ce-cli-20.10.8 containerd.io

Conclusion

In this article, we’ve shown you how to install a specific version of Docker on CentOS. By following these four simple steps, you can successfully install the Docker version you need and start using Docker for containerized development and deployment. If you encounter any issues, please refer to the official Docker documentation or community support.

Install Docker Engine on CentOS | Docker Documentation