官方说明:
Docker 需要安装在 64 位的平台,并且内核版本不低于 3.10。 CentOS 7 满足最低 内核的要求,但由于内核版本比较低,部分功能(如 overlay2 存储层驱动)无 法使用,并且部分功能可能不太稳定。

本次安装环境信息:
os版本:CentOS Linux release 7.8.2003
内核版本:3.10.0-1127.el7.x86_64

内核版本满足docker官方要求,docker应该可以安装成功。

使用aliyun的yum源开始安装:
1.部署yum源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2.执行安装命令
yum -y install docker-ce
安装失败报错信息:
--> Finished Dependency Resolution
Error: Package: containerd.io-1.2.13-3.2.el7.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2:2.74
Error: Package: 3:docker-ce-19.03.12-3.el7.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2:2.74
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

解决方法:
手动安装container-selinux
wget https://download.docker.com/linux/centos/7/x86_64/test/Packages/docker-ce-selinux-17.04.0.ce-0.1.rc1.el7.centos.noarch.rpm
rpm -ivh docker-ce-selinux-17.04.0.ce-0.1.rc1.el7.centos.noarch.rpm
安装该rpm包需要先安装依赖:
yum -y install policycoreutils-python
此时执行yum -y install docker-ce 依然失败,只得制定低版本的docker进行安装:
yum -y install docker-ce-17.03.3.ce-1.el7.x86_64
此时docker安装成功。

  1. 启动docker服务
    systemctl start docker
    systemctl enable docker

  2. 功能验证
    docker -v
    docker pull alpine

5.添加内核参数
执行 docker info 会有如下警告信息:
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
添加内核配置参数以启用这些功能:
sudo tee -a /etc/sysctl.conf <<-EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
然后重新加载 sysctl.conf 即可: sudo sysctl -p