Detailed steps for installing docker in 5 minutes

Time:2021-12-30

The operating system required for CentOS docker installation is CentOS 7 or 8, and the CentOS extras repository must be enabled. By default, this repository is enabled, but if it is disabled, you need to re enable it.

Uninstall old version

The old version of docker is called docker or docker engine. If there is an old version of docker, uninstall it together with related dependencies.


$ remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

Installation steps

It is officially recommended to install by setting up a docker warehouse. The installation and upgrade are simpler.

1. Set docker warehouse

You need to set up a docker warehouse during the first installation, and then you can use the warehouse to install and upgrade docker.

Need to install firstyum-utilsPackage, which can provideyum-config-managerStable warehouse for tools and configuration.


yum install -y yum-utils
 yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

2. Install docker engine

Install the latest version of docker engine and container, or go to the next step to formulate a version installation:


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

If you are prompted to accept the GPG key, verify whether it is060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, if so, accept.

If multiple docker repositories are enabled, installing or updating always installs the highest version available without specifying the version in the yum install or Yum update command, which may not be suitable for your stability needs.

The above command has installed the latest version of docker, but the service has not been started. The docker group has also been created, but no users have been assigned to the group.

3 install the specified version of docker engine

List all the versions available in the warehouse, and then select Install. The following command will sort the listed results in reverse order:


[[email protected] ~]# yum list docker-ce --showduplicates | sort -r
Last metadata expiration check: 0:32:38 ago on Fri 28 May 2021 06:17:26 PM CST.
Installed Packages
docker-ce.x86_64               3:20.10.6-3.el8                 docker-ce-stable 
docker-ce.x86_64               3:20.10.6-3.el8                 @docker-ce-stable
docker-ce.x86_64               3:20.10.5-3.el8                 docker-ce-stable 
docker-ce.x86_64               3:20.10.4-3.el8                 docker-ce-stable 
docker-ce.x86_64               3:20.10.3-3.el8                 docker-ce-stable 
docker-ce.x86_64               3:20.10.2-3.el8                 docker-ce-stable 
docker-ce.x86_64               3:20.10.1-3.el8                 docker-ce-stable 
docker-ce.x86_64               3:20.10.0-3.el8                 docker-ce-stable 
docker-ce.x86_64               3:19.03.15-3.el8                docker-ce-stable 
docker-ce.x86_64               3:19.03.14-3.el8                docker-ce-stable 
docker-ce.x86_64               3:19.03.13-3.el8                docker-ce-stable 
Available Packages

Specify the version to install through the following command, for example, for3:20.10.6-3.el8, its version number is:reach-The middle part, that is:20.10.6


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

Replace it with the version number. The above command is:


$ yum install docker-ce-20.10.6 docker-ce-cli-20.10.6 containerd.io

4 start docker


$ systemctl start docker

5 run Hello world
To verify that docker is installed correctly and started normally, execute the built-inhello-worldMirror.


$ docker container run hello-world

If thishello-worldThe image does not exist by default. It will be downloaded automatically, and then run the image.

The above is the details of the 5-minute installation tutorial of docker. For more information about the installation tutorial of docker, please pay attention to other relevant articles of developeppaer!