安装环境
查看Linux版本,如图:

下载docker yum源
登录阿里云开源镜像站,地址如下:
阿里云开源镜像站
搜索docker,如图:

打开docker-ce,如图:

复制docker-ce源地址,如下:
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
执行如下命令,下载docker-ce:
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
如图:

查看是否成功:


安装
执行如下命令安装docker:
yum -y install docker-ce
安装成功后,如图:

配置docker daemon启动文件
vi /usr/lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd
ExecStartPost=/sbin/iptables -P FORWARD ACCEPT

启动
执行如下命令:
systemctl start docker
查看是否启动成功:

常见问题:
错误一
This system is not registered with an entitlement server. You can use subscription-manager to register.
解决方法
红帽需要操作系统注册后才能使用yum,关闭注册功能,如下:
vi /etc/yum/pluginconf.d/subscription-manager.conf
将enabled配置改为0,如下:
[main]
enabled=0
如果报错如下:
File contains no section headers.
说明yum不可用。重新下载。
错误二
Error: Package: containerd.io-1.6.15-3.1.el7.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2:2.74
Error: Package: docker-ce-rootless-extras-20.10.23-3.el7.x86_64 (docker-ce-stable)
Requires: slirp4netns >= 0.4
Error: Package: 3:docker-ce-20.10.23-3.el7.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2:2.74
Error: Package: docker-ce-rootless-extras-20.10.23-3.el7.x86_64 (docker-ce-stable)
Requires: fuse-overlayfs >= 0.7
failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
解决方法
参考http://t.zoukankan.com/xuliang-daydayup-p-12740838.html