私有 Docker 注册表无法连接到 shell 和 Web 管理 UI?



>Background:

要在Windows 10 (x64)系统上的本地主机上的路径 c:\dkrreg处设置专用 docker 注册表服务器,已成功尝试以下命令:

docker run --detach --publish 1005:5000 --name docker-registry --volume /c/dkrreg:/var/lib/registry registry:2
docker pull hello-world:latest
docker tag hello-world:latest localhost:1005/hello-world:latest
docker push localhost:1005/hello-world:latest
docker pull localhost:1005/hello-world:latest

通过命令行从localhost:1005/hello-world:latest推送和拉取也会成功。

问题:

如果我通过docker pull 192.168.43.239:1005/hello-world:latest使用我的 IP 地址,它会在命令外壳中给出以下错误:

Error response from daemon: Get https://192.168.43.239:1005/v1/_ping: http: server gave HTTP response to HTTPS client

通过docker run --detach portainer:latest使用第三方 Docker UI 管理器时,它还显示连接错误为:

2017/04/19 14:30:24 http: proxy error: dial tcp [::1]:1005: getsockopt: connection refused

也尝试了其他东西。如何使用任何 Docker 管理 UI 工具连接从 LANlocalhost:1005的专用注册表服务器?

终于找到了解决这个问题的方法,这很棘手

  1. 生成 CA 私钥和证书作为ca-cert-mycompany.pemca-cert-key-companyname.pem。并配置了docker-compose.yml,将两个文件保存为:ro,位于以下位置/usr/local/share/ca-certificates/etc/ssl/certs//etc/docker/certs.d/mysite.com。但我也尝试只将证书复制到/usr/local/share/ca-certificates就足够了,因为 docker 会忽略重复的 CA 证书。这种额外的复制是因为在许多放置的码头工人研究员推荐了相同的内容。我没有执行命令:这次update-ca-certificates在注册表容器中,但与许多人的建议相反,我做得更早。

  2. docker-compose.yml中定义:随机数作为REGISTRY_HTTP_SECRET,以及服务器的链式证书(CA证书附加到其末尾)以REGISTRY_HTTP_TLS_CERTIFICATEamd服务器的公钥到REGISTRY_HTTP_TLS_KEY。已禁用 HTTP 身份验证。特别是对文件名使用了一些命名,如容器文件夹中的其他证书作为mysite.com_server-chained-certificate.crt,而不仅仅是certificate.crt

  3. V-Imp: 使用命令将证书推送到窗口中的受信任根certutil.exe -addstore root .Keysca-certificate.crt然后从任务栏图标重新启动适用于Windows的Docker,然后使用docker-compose up -d创建容器。这是最重要的一步,没有这个就没有效果。

现在可以执行docker pull mysite.com:1005/my-repo:my-tag

您需要向 Docker 守护程序指定您的注册表不安全: https://docs.docker.com/registry/insecure/

根据您的操作系统/系统,您需要更改守护程序的配置以指定注册表地址(格式IP:PORT,使用192.168.43.239:1005而不是localhost:1005)。

完成此操作后,您应该能够执行以下操作:

docker pull 192.168.43.239:1005/hello-world:latest

您还应该能够使用注册表字段中的192.168.43.239:1005通过Portainer访问它。

如果您想使用 Portainer 中的localhost:1005访问注册表,您可以尝试在host网络内运行它。

docker run --detach --net host portainer:latest

最新更新