【 docker学习问题记录-拉镜像巨慢,报错connect: network is unreachable】

在虚拟机上安装Docker后,尽管配置了阿里云镜像加速,下载镜像如redis时仍然速度缓慢,甚至报错。问题根源在于DNS问题。通过将系统DNS改为阿里云的DNS地址223.5.5.5,可以显著提高下载速度。修改/etc/resolv.conf文件,将nameserver更改为223.5.5.5,然后保存并重新尝试拉取镜像,问题得到解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述:在虚拟机上装完docker后,并且配置了阿里云镜像加速的情况下,下载镜像速度还是很慢,拉个redis镜像试了几十次都不行,报错如下:

<pre>[root@localhost docker]# docker pull redis
Using default tag: latest
latest: Pulling from library/redis
faef57eae888: Downloading  3.574MB/29.12MB
bb595d48e52d: Retrying in 5 seconds 
d479b54c3bb2: Retrying in 6 seconds 
4bd00b511c2c: Waiting 
286fb62a80b5: Waiting 
520d4480047f: Waiting 
error pulling image configuration: download failed after attempts=6: dial tcp [2606:4700::6812:7c19]:443: connect: network is unreachable
</pre>

于是遂百度之,搜了好多解决方案,换了一堆镜像源,还是不行,拉个redis镜像还是拉不下来,好在最后找到了解决方案:Docker拉取镜像过慢或卡死的坑!!!(亲测有效)

总结,DNS有问题,换成阿里云的DNS,几十秒就下载完毕了:
使用如下命令打开配置文件:

vi /etc/resolv.conf

显示如下:把nameserver 后面的IP改成223.5.5.5即可,保存退出,重新pull镜像,速度快的飞起

# Generated by NetworkManager
search localdomain
nameserver 223.5.5.5

vi命令使用步骤:按下 i 键(进入插入模式) --> 修改nameserver --> 修改完成按Esc键(进入命令行模式) --> 输入命令 :wq(退出并保存)

Err:1 http://archive.ubuntu.com/ubuntu jammy/universe amd64 wmdocker amd64 1.5-2 Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4000:1::103). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4002:1::102). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4000:1::101). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (185.125.190.81), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.83), connection timed out Err:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 docker all 1.5-2 Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4000:1::103). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4002:1::102). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4000:1::101). - connect (101: Network is unreachable) E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/d/docker/wmdocker_1.5-2_amd64.deb Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4000:1::103). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4002:1::102). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4000:1::101). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (185.125.190.81), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.83), connection timed out E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/d/docker/docker_1.5-2_all.deb Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4000:1::103). -
03-27
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CodePlayer大旭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值