我精确地遵循了Docker Registry安装文档,并在远程Ubuntu VM上运行了一个注册表。在该VM上,Docker容器使用以下命令运行:
docker run -d -p 5000:5000 --restart=always --name registry \
-v `pwd`/auth:/auth \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-v `pwd`/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/registry.key \
registry:2
在远程VM上,我有以下目录结构:
/home/myuser/
certs/
registry.crt
registry.key
/etc/docker/certs.d/myregistry.example.com:5000/
ca.crt
ca.key
ca.crt
与~/certs/registry.crt
完全相同(仅重命名); ca.key
和registry.key
相同/刚刚重命名也是如此。我根据您将在下面看到的错误输出中的建议创建了ca*
个文件。
我几乎 100%确定CA证书仍然有效,尽管有任何帮助裁定(例如我怎么能告诉?)将不胜感激。当我启动容器并查看Docker日志时,我没有看到任何错误。
然后我尝试从我的本地笔记本电脑(Mac)登录:
docker login myregistry.example.com:5000
它向我询问我的用户名,密码和电子邮件(虽然我不记得在设置Basic Auth时指定了电子邮件)。正确输入后(我已经检查并仔细检查过......)我收到以下错误:
myuser@mymachine:~/tmp$docker login myregistry.example.com:5000
Username: my_ciuser
Password:
Email: myuser@example.com
Error response from daemon: invalid registry endpoint https://myregistry.example.com:5000/v0/:
unable to ping registry endpoint https://myregistry.example.com:5000/v0/ v2 ping attempt failed with error:
Get https://myregistry.example.com:5000/v2/: x509: certificate has expired or is not yet valid
v1 ping attempt failed with error: Get https://myregistry.example.com:5000/v1/_ping: x509:
certificate has expired or is not yet valid. If this private registry supports only HTTP or
HTTPS with an unknown CA certificate, please add
`--insecure-registry myregistry.example.com:5000` to the daemon's
arguments. In the case of HTTPS, if you have access to the registry's CA
certificate, no need for the flag; simply place the CA certificate
at /etc/docker/certs.d/myregistry.example.com:5000/ca.crt
所以从我的角度来看,我猜以下是可能的:
任何想法/想法?
答案 0 :(得分:0)
如错误消息中所述:
...对于HTTPS,如果您有权访问注册表的CA. 证书,不需要国旗;只需放置CA证书即可 at /etc/docker/certs.d/myregistry.example.com:5000/ca.crt
其中myregistry.example.com:5000
- 您的CN与端口。
您应该将ca.crt
复制到将连接到Docker Registry的每个Docker守护程序并将其放在此文件夹中:/etc/docker/certs.d/myregistry.example.com:5000/ca.crt
执行此操作后,您需要重新启动Docker守护程序,例如,通过CentOS上的sudo service docker stop && service docker start
(或在您的操作系统上调用类似的程序)。
答案 1 :(得分:0)