【问题标题】:In Sonatype Nexus Docker proxy, how do I debug "Bad request" error?在 Sonatype Nexus Docker 代理中,如何调试“错误请求”错误?
【发布时间】:2021-11-17 23:06:32
【问题描述】:

我一直按照说明设置Proxy Repository for Docker。我打算为 Docker hub 设置一个代理,即https://index.docker.io/

我在 Nexus 上的设置详情

  • Nexus 版本 3.36.0-01
  • 通过docker-compose安装
  • 生成/安装的自签名证书
  • 使用内置 https/jetty,NOT 反向代理
  • http 监听 80 端口
  • https 监听 443 端口

我在 Nexus docker proxy repo 上的设置详情

  • 为 https 配置,端口 8443
  • 代理远程存储:https://registry-1.docker.io
  • 代理docker索引:“使用docker hub”,预填为https://index.docker.io/
  • 允许匿名 docker pull
  • 启用 Docker Bearer Token Realm
  • 启用 docker v1 API
  • 启用外部层缓存

我在 Ubuntu docker 客户端上的设置详情

  • /etc/docker/certs.d 中的可信自签名证书
  • /usr/local/share/ca-certificates + update-ca-certificates 中的可信自签名证书
  • /etc/docker/daemon.json 中启用 Docker 守护程序调试
  • 通过httpsProxy/home/myuser/.docker/config.json 中启用Docker 代理
  • 通过httpsProxy in /etc/systemd/system/docker.service.d/https-proxy.conf 启用 Docker 代理,重新加载/重新启动 Docker 守护进程

我的客户测试

  • docker pull hello-world:latest
  • 返回错误Error response from daemon: Get https://registry-1.docker.io/v2/: Bad Request
  • 在调试日志中:
Nov 17 22:53:17 myclient dockerd[20160]: time="2021-11-17T22:53:17.190545462Z" level=debug msg="Calling HEAD /_ping"
Nov 17 22:53:17 myclient dockerd[20160]: time="2021-11-17T22:53:17.190878019Z" level=debug msg="Calling GET /v1.40/info"
Nov 17 22:53:17 myclient dockerd[20160]: time="2021-11-17T22:53:17.213218413Z" level=debug msg="Calling POST /v1.40/images/create?fromImage=hello-world&tag=latest"
Nov 17 22:53:17 myclient dockerd[20160]: time="2021-11-17T22:53:17.213290250Z" level=debug msg="Trying to pull hello-world from https://registry-1.docker.io v2"
Nov 17 22:53:17 myclient dockerd[20160]: time="2021-11-17T22:53:17.234803592Z" level=warning msg="Error getting v2 registry: Get https://registry-1.docker.io/v2/: Bad Request"
Nov 17 22:53:17 myclient dockerd[20160]: time="2021-11-17T22:53:17.234865780Z" level=info msg="Attempting next endpoint for pull after error: Get https://registry-1.docker.io/v2/: Bad Request"
Nov 17 22:53:17 myclient dockerd[20160]: time="2021-11-17T22:53:17.234976364Z" level=error msg="Handler for POST /v1.40/images/create returned error: Get https://registry-1.docker.io/v2/: Bad Request"

后续步骤

发生这种情况时,我正在查看服务器上的日志。它显示没有错误。然而,客户端似乎表明该请求正在部分工作。

我尝试按照this other SO question/answer 将 org.apache.http.wire 增加到 DEBUG,但这也没有显示任何内容。

如何继续调试?

【问题讨论】:

    标签: docker nexus nexus3


    【解决方案1】:

    如果您检查 docker 输出,您会注意到它不会连接到 nexus,它正在向 https://registry-1.docker.io 发出请求。要从 Nexus 拉取,您需要将主机和端口添加到拉取请求中。

    docker pull hostname:8443/hello-world:latest
    

    顺便说一句,docker 中没有任何方法可以将其默认设置为私有注册表,因此您总是需要预先添加 host:port。

    【讨论】:

    最近更新 更多