Docker国内加速无法下载镜像怎么处理

以下方式2024-09-14在CentOS测试有效

1.修改系统yum

# 文件路径 /etc/yum.repos.d/CentOS-Vault.repo
# Vault
[Vault-base]
name=Vault - CentOS-$releasever - Base
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-$releasever

[Vault-updates]
name=Vault - CentOS-$releasever - Updates
baseurl=http://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-$releasever

[Vault-extras]
name=Vault - CentOS-$releasever - Extras
baseurl=http://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-$releasever

2.mv 旧版本 Base

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

3.设置docker 仓库

yum install -y yum-utils
yum-config-manager --add-repo=https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4.安装docker 组件

yum install -y yum-utils device-mapper-persistent-data lvm2
yum localinstall  containerd.io-1.6.26-3.1.el7.x86_64.rpm docker-ce-24.0.7-1.el7.x86_64.rpm docker-ce-cli-24.0.7-1.el7.x86_64.rpm

5.配置docker 加速器
修改"/etc/docker/daemon.json"文件(如果没有,可以手动创建),在该文件内添加如下内容:

vi /etc/docker/daemon.json

{
  "registry-mirrors": ["https://57ee7c4b76a3431580426a95740a8dd2.mirror.swr.myhuaweicloud.com", "https://docker.m.daocloud.io"]
}
posted @ 2024-09-14 16:20  minseo  阅读(27)  评论(0编辑  收藏  举报