在工作中 docker 无法拉取镜像:
[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)
如果我手动尝试访问第二个 URL,它也会可靠地导致 401。
然而在家里,相同的命令以某种方式设法成功检索标签:
[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
[...]
问题是:这个 docker 实例是如何设法获得 200 结果的?
有没有什么好的方法可以检查通信? (Wireshark 可能不太好,因为 https 是完全加密的。)
可能唯一的方法是阅读 source code .但是我对go语言了解不多。
你能想到更好的解决方案吗,我自己构建 docker 并添加一些调试打印?
最佳答案
似乎是 REST 调用 requires一个有效的 Authorization: Token ...
header 。似乎公司代理也破坏了该 header 。 :(
从源代码构建 docker 真的很轻松。
关于http - docker如何设法获得200而不是401的返回码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24340783/