1、确定你是CentOS7及以上版本
cat /etc/redhat-release
![在这里插入图片描述](https://img-blog.csdnimg.cn/76bbbb26dba046fd83922f61bee5d4bc.png)
2、yum安装gcc相关包(需要确保虚拟机可以上外网 )
yum -y install gcc
yum -y install gcc-c++
3、安装其他软件包
yum install -y yum-utils
4、设置stable镜像仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5、更新yum软件包索引
yum makecache fast
6、安装Docker CE
yum install -y docker-ce docker-ce-cli containerd.io
7、启动docker
systemctl start docker
8、测试
docker version
docker run hello-world
docker images
9、配置加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://3hrtt901.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker