前言

本文旨在解决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) 这一类情况。

最近又要用到docker,期间遇到此问题,故简单记录一下。(现在发现要把博客写的简单明了,写者写着不费时间,读者读着不费力气,也是一种很大很大的技术)

1 问题描述

我的系统是windows 10系统(专业版)。

在打开cmd命令行之后,输入docker pull ubuntu:14.04(即下载Ubuntu 14 版本的镜像image),报错如下:

F:\docker>docker pull ubuntu:14.04
Error response from daemon: Get https://registry-1.docker.io/v2/library/ubuntu/manifests/14.04: Get https://auth.docker.io/token?account=dalewushuang&scope=repository%3Alibrary%2Fubuntu%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

百思不得解,中间也试了很多方案,如输入docker login,报错如下:

C:\Users\dehen>docker login
Authenticating with existing credentials…
Login did not succeed, error: 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)
Login with your Docker ID to push and pull images from Docker Hub. If you don’t have a Docker ID, head over to https://hub.docker.com to create one.
Username (dalewushuang):
Password:
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)

2 解决方案

即将docker中的Network中的DNS server设置如下:
在这里插入图片描述

然后docker会自动重启(restart),重启只会再输入docker pull ubuntu:14.04,就能很顺利的下载指定镜像了。

总结

以上。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐