告別Docker請求超時之一步步排查與詳細解決方案
docker運行系統(tǒng)
系統(tǒng):Ubuntu
問題現象
在ubuntu系統(tǒng)上面,安裝完Docker后,嘗試運行 docker run hello-world 來測試docker安裝是否成功的時候,報錯,報錯信息如下:
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers). See 'docker run --help'.
解決方案
對于這種連接超時的問題,網上有很多的解決方案,我也根據網上的解決方案嘗試了,但是有些處理方案不起作用,也在下面處理方案列出,希望對你們有所幫助。
1. 修改docker鏡像源 (本地修改后不行)
使用命令 sudo vim /etc/docker/daemon.json (若文件不存在,會自動創(chuàng)建一個新的daemon.json文件),替換文件中的鏡像源信息
{
"registry-mirrors": ["https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn"]
}修改后需重新docker服務
sudo systemctl daemon-reload sudo systemctl restart docker
檢查是否生效:查看docker系統(tǒng)信息 docker info,查看 registry mirror 中剛配置的內容地址。
2. 修改DNS服務配置
- 查看DNS服務配置,
/etc/resolv.conf
cat /etc/resolv.conf
- 查看nameserver后面IP地址信息,或者顯示的IP地址有問題,可以嘗試修改該文件。
nameserver 114.114.114.114 nameserver 8.8.8.8
3. 獲取可用的鏡像源(成功拉取鏡像源)
以上方法都不起作用后,找了很久,終于找到一個可用的鏡像源
https://docker.rainbond.cc/
將上述信息添加到damon.json文件中,然后重啟服務,docker run hello-world 嘗試拉取鏡像,成功。
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:d211f485f2dd1dee407a80973c8f129f00d54604d2c90732e8e320e5038a0348
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
總結:
在這篇博客中,提供了一系列處理Docker拉取鏡像超時的實用的解決方案。我們首先分析了網絡連接問題、DNS配置錯誤以及代理設置等可能導致該錯誤的因素。接著,我們詳細講解了如何通過調整Docker配置文件、修改DNS選項以及檢查系統(tǒng)代理設置等方法來解決這一問題。
通過這些步驟,相信你已經能夠有效地解決“Client.Timeout exceeded while awaiting headers”錯誤,讓你的Docker容器順利運行。掌握這些技巧,不僅能幫助你處理當前的問題,也為你在未來面對類似挑戰(zhàn)時提供了有力的工具。
希望這篇教程對你有所幫助,助你在Docker的使用過程中更加得心應手。謝謝閱讀,期待你的反饋!
到此這篇關于Docker請求超時排查與詳細解決方案的文章就介紹到這了,更多相關Docker請求超時排查與解決內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
docker可視化管理工具portainer忘記密碼重置教程的實現
本文主要介紹了docker可視化管理工具portainer忘記密碼重置教程的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-08-08
Docker學習筆記之Docker部署Java web系統(tǒng)
這篇文章主要介紹了Docker學習筆記之Docker部署Java web系統(tǒng),小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-02-02
docker配置鏡像Docker pull時報錯:https://registry-1.docker.io/v
Docker拉鏡像報錯的原因可能是網絡問題、認證問題、注冊中心URL不正確或注冊中心服務不可用,解決方法包括重載和重啟Docker服務2026-01-01

