[Tutorial] Updating CentOS 7 Mirror to Aliyun
Problem Description
As the CentOS 7 is no longer maintained, the default mirror is not available. We need to update the CentOS 7 mirror to the Aliyun mirror even we pull the official CentOS 7 image from Docker Hub.
Updating the CentOS 7 Mirror
sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009|g" \
-i.bak \
/etc/yum.repos.d/CentOS-Base.repo
Then run:
yum clean
yum makecache
Explanation
- The
sed
command is used to replace themirrorlist
andbaseurl
in the CentOS 7 repository configuration file with the Aliyun mirror URL. - We only replace the
CentOS-Base.repo
file in the/etc/yum.repos.d/
directory, which is the default repository configuration file for CentOS 7. Other repository configuration files will be updated automatically when we runyum makecache
. - The
yum clean
command is used to clean the cache of the old mirror, and theyum makecache
command is used to update the cache with the new mirror.