1.卸载旧版本
dnf remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
2.配置dnf
dnf -y install dnf-plugins-core
# 使用阿里源
dnf config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/fedora/docker-ce.repo
sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
3. 安装docker
dnf update
dnf install docker-ce docker-ce-cli containerd.io
# 设置开机启动
systemctl enable docker
systemctl start docker
4. 配置阿里云镜像加速
tee /etc/docker/daemon.json << 'EOF'
{
"registry-mirrors":["https://rsbud4vc.mirror.aliyuncs.com","https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://dockerhub.azk8s.cn","http://hub-mirror.c.163.com","http://qtid6917.mirror.aliyuncs.com","https://rncxm540.mirror.aliyuncs.com","https://e9yneuy4.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload && systemctl restart docker