描述:在win10下安装VM,在VM里运行docker,使用docker pull
拉取镜像时报错
-
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
原因:使用
docker pull
命令拉取镜像时,如果不添加额外的信息如docker pull nginx
,则会默认镜像拉取地址为国外仓库,导致DNS解析超时。
解决办法:- )修改VM默认的DNS为8.8.8.8
- )使用国内的镜像仓库拉取镜像
-
Trying to pull repository docker.io/library/nginx ... Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
原因:也是因为使用国外地址,导致http握手失败。
解决办法:- )每次拉取镜像时都手动指定国内仓库地址
docker pull registry.docker-cn.com/library/nginx
- )修改 /etc/docker/daemon.json 文件(把默认仓库地址修改为国内地址,省去每次都手动输入)
vim /etc/docker/daemon.json
-> 写入
{ "registry-mirrors": ["https://registry.docker-cn.com"] }
最后,重启docker即可systemctl daemon-reload
+systemctl restart docker
- )每次拉取镜像时都手动指定国内仓库地址
-
吐槽一下CSDN的markdown是真心难用,很多语法都不支持。