ARM64架构的CentOS7 更新yum源下载vim和net-tools工具yum 换源一键换源DockerFile 换源yum 换源我使用yum 下载vim 和 net-tools 工具总是下载失败如果不安装这两个软件就不能使用 vim 和 ifconfig 命令。我尝试使用网上的其它办法对 yum 换源但总是报错如下因为我的本地主机是 ARM64 架构的出现这一问题的本质还是因为没有换对源进过数次尝试发现ARM架构的 centOS7 需要换成Centos-altarch-7.repo这个版本的源才行。如果你是其它架构或系统版本 如 x86_64 位的或者其它架构可以在该网站上找到合适的源阿里换源如果你跟我的架构和centos版本一样也可以直接复制下面的内容替换 /etc/yum.repos.d/CentOS-Base.repo 中的内容注意文件名不能变只是把内容换了Centos-altarch-7.repo 内容如下# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist does not work for you, as a fall back you can try the # remarked out baseurl line instead. # # [base] nameCentOS-$releasever - Base baseurlhttp://mirrors.aliyun.com/centos-altarch/$releasever/os/$basearch/ gpgcheck0 gpgkeyhttp://mirrors.aliyun.com/centos-altarch/7/os/$basearch/RPM-GPG-KEY-CentOS-7 #released updates [updates] nameCentOS-$releasever - Updates baseurlhttp://mirrors.aliyun.com/centos-altarch/$releasever/updates/$basearch/ gpgcheck0 gpgkeyhttp://mirrors.aliyun.com/centos-altarch/7/os/$basearch/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] nameCentOS-$releasever - Extras baseurlhttp://mirrors.aliyun.com/centos-altarch/$releasever/extras/$basearch/ gpgcheck0 gpgkeyhttp://mirrors.aliyun.com/centos-altarch/7/os/$basearch/RPM-GPG-KEY-CentOS-7 enabled1 #additional packages that extend functionality of existing packages [centosplus] nameCentOS-$releasever - Plus baseurlhttp://mirrors.aliyun.com/centos-altarch/$releasever/centosplus/$basearch/ gpgcheck0 enabled0 gpgkeyhttp://mirrors.aliyun.com/centos-altarch/7/os/$basearch/RPM-GPG-KEY-CentOS-7一键换源上面讲述了问题的原因和解决办法这里提供一个直接替换源的方法直接执行curl-o/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-altarch-7.repo# 刷新yum缓存yum clean all yum makecache注意这是小写的 o如果使用 wget 命令有可能你的系统没有安装 wget 命令所以用上面的比较直接方便。然后就可以顺利使用 yum 下载想下载的软件工具了例如下载 vim 和 net-tools 工具yum-yinstallvimyum-yinstallnet-toolsDockerFile 换源在 DockerFile 中如果需要更换镜像系统的 yum 源还是以 我的 ARM64 架构下的CentOS7版本的为例# 指定基础镜像 FROM centos:7 # 创建一个环境变量 ENV MYHOME /home # 登录进入容器后的所处位置 WORKDIR $MYHOME # *** 重点 ***更换 yum 源 RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-altarch-7.repo RUN yum clean all RUN yum makecache # 安装所需软件 RUN yum -y install vim RUN yum -y install net-tools # 暴露 80 端口 EXPOSE 80 # 运行容器后默认的执行命令打开bash窗口 CMD /bin/bash