Docker supports the following 64-bit CentOS versions:
CentOS 7
CentOS 8
A higher version.
2.5.1. Use the official installation script to install automatically ¶
The installation commands are as follows:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
You can also use the domestic daocloud one-click installation command:
curl -sSL https://get.daocloud.io/docker | sh
2.5.2. Manual installation ¶
Uninstall the old version ¶
Older versions of Docker are called docker or docker-engine. If you have installed these programs, uninstall them and related dependencies.
$ sudo yum remove docker \\
docker-client \\
docker-client-latest \\
docker-common \\
docker-latest \\
docker-latest-logrotate \\
docker-logrotate \\
docker-engine
Install Docker Engine-Community ¶
Use the Docker repository for installation ¶
Before installing Docker Engine-Community on the new host for the first time, you need to set up the Docker repository. You can then install and update Docker from the repository.
设置仓库
Install the required software packages. Yum-utils provides yum-config-manager, and the device mapper storage driver requires device-mapper-persistent-data and lvm2.
$ sudo yum install -y yum-utils \\
device-mapper-persistent-data \\
lvm2
Use the following command to set up a stable warehouse.
Use the official source address (slow)
$ sudo yum-config-manager \\
--add-repo \\
https://download.docker.com/linux/centos/docker-ce.repo
You can choose some domestic source addresses:
Ali Yun
$ sudo yum-config-manager \\
--add-repo \\
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Source of Tsinghua University
$ sudo yum-config-manager \\
--add-repo \\
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
Install Docker Engine-Community ¶
Install the latest version of Docker Engine-Community and containerd, or go to the next step to install a specific version:
$ sudo yum install docker-ce docker-ce-cli containerd.io
If you are prompted to accept the GPG key, select Yes.
有多个 Docker 仓库吗?
If multiple Docker repositories are enabled, installations or updates that do not specify a version in the yum install or yum update command will always install the highest version, which may not suit your stability needs.
The Docker installation is not started by default. And the docker user group has been created, but there are no users under that user group.
要安装特定版本的 Docker Engine-Community,请在存储库中列出可用版本,然后选择并安装:
1、列出并排序您存储库中可用的版本。此示例按版本号(从高到低)对结果进行排序。
$ yum list docker-ce --showduplicates \| sort -r
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
2、通过其完整的软件包名称安装特定版本,该软件包名称是软件包名称(docker-ce)加上版本字符串(第二列),从第一个冒号(:)一直到第一个连字符,并用连字符(-)分隔。例如:docker-ce-18.09.1。
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
Start Docker.
$ sudo systemctl start docker
Verify that Docker Engine-Community is installed correctly by running the hello-world image.
$ sudo docker run hello-world
Uninstall docker ¶
Delete the installation package:
yum remove docker-ce
Delete images, containers, configuration files, etc.:
rm -rf /var/lib/docker