Docker官网 Install Docker Engine on CentOS | Docker Docs
1.查看系统版本,Docker支持CentOS 7及以上版本
cat /etc/redhat-release
2.卸载旧版本
sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine
3.安装依赖
yum install -y gcc
yum install -y gcc c++
yum install -y yum-utils
4.设置阿里云镜像库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5.安装Docker CE
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
6.启动 Docker
systemctl start docker
7.验证安装
#查看版本
docker version
docker run hello-world
docker run hello-world