英文:
How does docker manage to get a return code of 200 instead of 401
问题
在工作中,Docker无法拉取镜像:
[b209d3c5] +job pull(ubuntu, )
[debug] registry.go:372 [registry] 调用 GET https://index.docker.io/v1/repositories/ubuntu/images
[debug] http.go:160 https://index.docker.io/v1/repositories/ubuntu/images -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.15.1-1-ARCH os/linux arch/amd64]]
[debug] server.go:1182 检索标签列表
[debug] http.go:160 https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.15.1-1-ARCH os/linux arch/amd64]]
[debug] registry.go:327 从 https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags 获取状态码 401
[error] server.go:1185 无法连接到任何注册表端点
无法连接到任何注册表端点
[b209d3c5] -job pull(ubuntu, ) = ERR (1)
如果我手动尝试访问第二个URL,结果也会可靠地返回401。
然而,在家里,相同的命令以某种方式成功地检索到了标签:
[4e9acee4] +job pull(ubuntu, )
[debug] registry.go:372 [registry] 调用 GET https://index.docker.io/v1/repositories/ubuntu/images
[debug] http.go:160 https://index.docker.io/v1/repositories/ubuntu/images -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.14.6-1-ARCH os/linux arch/amd64]]
[debug] server.go:1182 检索标签列表
[debug] http.go:160 https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.14.6-1-ARCH os/linux arch/amd64]]
[debug] registry.go:327 从 https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags 获取状态码 200
[debug] server.go:1197 注册标签
[...]
问题是:这个Docker实例是如何获得200的结果的?
有没有一种好的方法来检查通信?(Wireshark可能不适用,因为HTTPS是完全加密的。)
可能唯一的方法是阅读源代码。但是我对Go语言了解不多。
你能想到任何更好的解决方案吗?比如自己构建Docker并添加一些调试打印信息?
英文:
At work docker is not able to pull images:
[b209d3c5] +job pull(ubuntu, )
[debug] registry.go:372 [registry] Calling GET https://index.docker.io/v1/repositories/ubuntu/images
[debug] http.go:160 https://index.docker.io/v1/repositories/ubuntu/images -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.15.1-1-ARCH os/linux arch/amd64]]
[debug] server.go:1182 Retrieving the tag list
[debug] http.go:160 https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.15.1-1-ARCH os/linux arch/amd64]]
[debug] registry.go:327 Got status code 401 from https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags
[error] server.go:1185 Could not reach any registry endpoint
Could not reach any registry endpoint
[b209d3c5] -job pull(ubuntu, ) = ERR (1)
If I manually try to access that second URL it reliably results in a 401, too.
However at home the same command somehow manages to successfully retrieve the tags:
[4e9acee4] +job pull(ubuntu, )
[debug] registry.go:372 [registry] Calling GET https://index.docker.io/v1/repositories/ubuntu/images
[debug] http.go:160 https://index.docker.io/v1/repositories/ubuntu/images -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.14.6-1-ARCH os/linux arch/amd64]]
[debug] server.go:1182 Retrieving the tag list
[debug] http.go:160 https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags -- HEADERS: map[User-Agent:[docker/1.0.0 go/go1.2.2 git-commit/63fe64c kernel/3.14.6-1-ARCH os/linux arch/amd64]]
[debug] registry.go:327 Got status code 200 from https://cdn-registry-1.docker.io/v1/repositories/library/ubuntu/tags
[debug] server.go:1197 Registering tags
[...]
The question is: How did this docker instance manage to get a 200 result?
Is there a good way to inspect the communication? (Wireshark is probably not good as https is completely encrypted.)
Probably the only way is reading the source code. But I don't know much about the go language.
Can you think of any better solution that, building docker on my own and adding some debugging prints?
答案1
得分: 1
似乎这个 REST 调用需要一个有效的 Authorization: Token ...
头部。而且似乎公司的代理服务器破坏了这个头部。:(
从源代码构建 Docker 真的很简单。
英文:
Seems like that REST call requires a valid Authorization: Token ...
header. Also seems like the company proxy breaks that header.
Building docker from source is really painless.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论