Wil*_*lem 31 linux-networking docker
我一直得到这个(Ubuntu 16.04 LTS):
$ docker pull nginx
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
Run Code Online (Sandbox Code Playgroud)
但是 curl TLS 工作正常(除了身份验证错误):
$ curl https://registry-1.docker.io/v2/
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
Run Code Online (Sandbox Code Playgroud)
甚至一个小的 golang 程序(模仿 docker)也能正常工作:
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
resp, err := http.Get("https://registry-1.docker.io/v2/")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println("Got: ", string(body))
}
Run Code Online (Sandbox Code Playgroud)
docker TLS 超时请求的 pcap:
reading from file docker-timeout.pcap, link-type LINUX_SLL (Linux cooked)
00:38:54.782452 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [S], seq 26945613, win 29200, options [mss 1460,sackOK,TS val 1609360 ecr 0,nop,wscale 7], length 0
00:38:54.878630 IP registry-1.docker.io.https > my-ubuntu.52036: Flags [S.], seq 2700732154, ack 26945614, win 26847, options [mss 1460,sackOK,TS val 947941366 ecr 1609360,nop,wscale 8], length 0
00:38:54.878691 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [.], ack 1, win 229, options [nop,nop,TS val 1609384 ecr 947941366], length 0
00:38:54.878892 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1609384 ecr 947941366], length 155
00:38:55.175931 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1609459 ecr 947941366], length 155
00:38:55.475954 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1609534 ecr 947941366], length 155
00:38:56.076327 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1609684 ecr 947941366], length 155
00:38:57.280103 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1609985 ecr 947941366], length 155
00:38:59.684095 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1610586 ecr 947941366], length 155
00:39:04.492102 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1611788 ecr 947941366], length 155
00:39:04.879468 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [F.], seq 156, ack 1, win 229, options [nop,nop,TS val 1611884 ecr 947941366], length 0
00:39:04.976015 IP registry-1.docker.io.https > my-ubuntu.52036: Flags [.], ack 1, win 105, options [nop,nop,TS val 947943890 ecr 1609384,nop,nop,sack 1 {156:157}], length 0
00:39:04.976073 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1611909 ecr 947943890], length 155
00:39:05.275922 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1611984 ecr 947943890], length 155
00:39:05.876104 IP my-ubuntu.52036 > registry-1.docker.io.https: Flags [P.], seq 1:156, ack 1, win 229, options [nop,nop,TS val 1612134 ecr 947943890], length 155
Run Code Online (Sandbox Code Playgroud)
可能出什么问题了?
小智 25
net/http: TLS handshake timeout意味着您的互联网连接速度较慢。连接超时的默认值对于您的环境来说太小了。不幸的是,docker 没有任何允许您更改连接超时的设置。您可以尝试在其他地方创建自己的注册表缓存并从中提取图像。
小智 9
我遇到了同样的问题。然后 Azamat Hackimov 的回答为我指明了正确的方向。我的机器有点慢,特别是在启动时,当我想启动服务时。因此,短暂的超时开始并终止了我的请求。
这是我的解决方法:
docker pull $IMAGE || docker pull $IMAGE || docker pull $IMAGE || docker pull $IMAGE
Run Code Online (Sandbox Code Playgroud)
简单地用请求锤击服务器。通常第二个对我来说是成功的。
我有一个同样的问题,通过使用docker run hello-world第 1 次,导致使用 下载图像https://registry-1.docker.io/v2/,最终
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: proxyconnect tcp: net/http: TLS handshake timeout.
Run Code Online (Sandbox Code Playgroud)
在网上搜索了几个小时,发现这种情况发生在一些使用 ubuntu 18.04 和当前 docker 版本的用户身上,在代理后面。解决方法是删除所有 https 代理配置,以便仅保留 http 代理配置,以强制进行 http(而非 https)下载。
不知道,真正的原因是什么。
(顺便说一句:我有一个与 composer 和 packagist 相同的“TLS 握手”问题。这是因为缺少 cacert.pem 文件,默认情况下该文件不是由 ubuntu 提供的。也许这个 docker-problem 正朝着同一个方向发展?)
小智 6
如果您使用的是私有注册,你需要把证书,根据/etc/docker/certs.d/ registryname /ca.crt
注册表名称将相应更改
另外,请将您的MTU大小更改为 1300,这也是我为解决错误所做的一件事。注册表一 我相信您可能已经完成了。MTU 更改命令
ip link set dev eth0 mtu 1300
如果您的互联网速度非常好,请检查 MTU 大小以避免出现此错误
小智 5
在我的情况下,我的服务器在 nat 和代理后面,并设置为自动检测代理我在当前终端上所做的事情我有导出代理设置
root@k8master:~/runner# export http_proxy="http://192.168.10.208:3128"
root@k8master:~/runner# docker pull gitlab/gitlab-runner:latest
latest: Pulling from gitlab/gitlab-runner
7b722c1070cd: Pull complete
5fbf74db61f1: Pull complete
ed41cb72e5c9: Pull complete
7ea47a67709e: Pull complete
ae336ceeca88: Pull complete
f9f79780e6cf: Pull complete
67e622273f37: Pull complete
bc84c40af701: Pull complete
69e36092e9de: Pull complete
Digest: sha256:b1f5387942aaaf8c220f6613a1e96ba2cbcb6c58a5e47ca0df8ae3216720a15e
Status: Downloaded newer image for gitlab/gitlab-runner:latest
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
106462 次 |
| 最近记录: |