1.先更新yum
yum update
报错:
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
解决:
运行以下两条命令修改yum存储库镜像源。
进入 /etc/yum.repos.d/
cd /etc/yum.repos.d/
-
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
-
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
此时可以运行yum update
2.安装yum工具
yum install -y yum-utils device-mapper-persistent-data lvm2
3.设置yum镜像
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
4.安装docker
yum install -y docker-ce
报错:
Problem: package docker-ce-3:24.0.7-1.el8.aarch64 requires containerd.io >= 1.6.4, but none of the providers can be installed
改用命令:
yum install -y --allowerasing docker-ce
5.安装完成,查看版本
systemctl start docker
docker -v
6.docker仓库配置镜像
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["<https://as08lme3.mirror.aliyuncs.com>"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker