解决方法:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://do.nark.eu.org",
"https://dc.j8.work",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
然后运行容器:
[root@localhost ~]# docker run -it --name=c1 centos:latest /bin/bash
[root@333dce61a32d /]#
[root@ad1f65bc788f /]# ps
[root@ad1f65bc788f /]# uptime
将容器中的/etc/yum.repos.d/CentOs-Base.repo 文件中修改成:
[baseos]
name=CentOS-$releasever - BaseOS
baseurl=https://vault.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[appstream]
name=CentOS-$releasever - AppStream
baseurl=https://vault.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
这样就解决了无法下载的问题