You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RHEL 7.9服务器安装Docker CE遇域名解析错误求助

在RHEL 7.9 (Maipo) x86_64上安装Docker CE时的DNS解析失败问题

执行安装命令:

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

触发如下错误:

Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: download.docker.com; Unknown error"
Trying other mirror.

One of the configured repositories failed (Docker CE Stable - x86_64),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

1. Contact the upstream for the repository and get them to fix the problem.

 2. Reconfigure the baseurl/etc. for the repository, to point to a working
    upstream. This is most often useful if you are using a newer
    distribution release than is supported by the repository (and the
    packages for the previous distribution release still work).

 3. Run the command with the repository temporarily disabled
        yum --disablerepo=docker-ce-stable ...

 4. Disable the repository permanently, so yum won't use it by default. Yum
    will then just ignore the repository until you permanently enable it
    again or use --enablerepo for temporary usage:

        yum-config-manager --disable docker-ce-stable
    or
        subscription-manager repos --disable=docker-ce-stable

 5. Configure the failing repository to be skipped, if it is unavailable.
    Note that yum will try to contact the repo. when it runs most commands,
    so will have to try and fail each time (and thus. yum will be be much
    slower). If it is a very temporary problem though, this is often a nice
    compromise:

        yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: download.docker.com; Unknown error"

单独测试curl命令:

curl https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml

报错:curl: (6) Could not resolve host: download.docker.com; Unknown error

但浏览器可正常访问该URL。


解决方法

1. 检查并修复DNS配置

  • 查看当前DNS服务器:
    cat /etc/resolv.conf
    
  • 若DNS服务器异常,替换为公共DNS(如8.8.8.8、114.114.114.114):
    编辑/etc/resolv.conf,添加或修改:
    nameserver 8.8.8.8
    nameserver 114.114.114.114
    
  • 保存后重新测试curl:
    curl https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml
    

2. 清除yum缓存并重配Docker仓库

  • 清除现有yum缓存:
    sudo yum clean all
    sudo rm -rf /var/cache/yum
    
  • 重新添加Docker CE仓库:
    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
  • 再次尝试安装:
    sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    

3. 排查代理与防火墙设置

  • 检查代理配置:
    查看当前环境变量:
    echo $http_proxy $https_proxy
    
    若浏览器通过代理访问,需给yum和curl配置代理:
    临时设置:
    export http_proxy=http://your-proxy-ip:port
    export https_proxy=http://your-proxy-ip:port
    
    永久配置(编辑/etc/yum.conf):
    proxy=http://your-proxy-ip:port
    
  • 临时关闭防火墙测试:
    sudo systemctl stop firewalld
    
    若恢复正常,需添加入站/出站规则允许DNS(UDP 53)和HTTPS(TCP 443)流量。

4. 手动添加hosts解析

  • 通过其他设备获取download.docker.com的有效IP(如用ping/nslookup),编辑/etc/hosts:
    99.84.220.250 download.docker.com
    
    (IP地址可能变动,需确认当前有效)
  • 保存后重新测试curl和yum安装。

内容的提问来源于stack exchange,提问作者Vishal Nagvadiya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 16:05:45