如果你想连接私有镜像服务器,请看下面的简单步骤。
比如你有一台私有镜像服务器test.example.com:443
1) 先得到该服务器的 公钥(public key)
$ openssl s_client -showcerts -connect test.example.com:443
将其输出结果中的公钥复制出来
$ openssl s_client -showcerts -connect test.example.com:443
CONNECTED(00000003)
depth=0 C = US, O = Docker, OU = Docker, L = San Francisco, CN = test.example.com
verify error:num=18:self signed certificate
verify return:1
depth=0 C = US, O = Docker, OU = Docker, L = San Francisco, CN = test.example.com
Certificate chain
0 s:/C=US/O=Docker/OU=Docker/L=San Francisco/CN=test.example.com
i:/C=US/O=Docker/OU=Docker/L=San Francisco/CN=test.example.com
-----BEGIN CERTIFICATE-----
MIIFsjCCA5qgAwIBAgIRALRtKdj9DyxVtWXgQYDUIOAwDQYJKoZIhvcNAQELBQAw
YjELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkRvY2tlcjEPMA0GA1UECxMGRG9ja2Vy
MRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRkwFwYDVQQDExB0ZXN0LmV4YW1wbGUu
Y29tMB4XDTE2MDIyODIwMzYzNVoXDTE3MDIyNzIwMzYzNVowYjELMAkGA1UEBhMC
VVMxDzANBgNVBAoTBkRvY2tlcjEPMA0GA1UECxMGRG9ja2VyMRYwFAYDVQQHEw1T
YW4gRnJhbmNpc2NvMRkwFwYDVQQDExB0ZXN0LmV4YW1wbGUuY29tMIICIjANBgkq
hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqVOIkSOQGdTN+/xv01lZo2ICs+VVGU+Q
auPF/bKI/5WUQCIjb9QF+voprzRD5Etwym11QIqnIk6XnQwe25mJwMu1ZkGN3ZF/
gcCXlh44Yam2VB2VU0A0wAFO395ZJbj20ma2R8b9+XQkk3SnnpSKWzkCJphvn6PV
8nk3GN3l+U6lSBZhNQkybvya9no0IOcEVXkDNf4aoRJukRxcl/8kJqgJchyk1Qs4
UY3KFSSuxDqMGOcX3zbIhIZfW7yVlVtt4H/BnzzxAkdJvgiKOMXg8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GSKJXCzc6HcsGlu6+EumkA7kvUGZRX7oZmod9v6GU1
klTb370cFMy7Dn2Fq4iubM85P3bOMai8hT48nVa2WTJPik1b6WvJhzl1ZZOVc9Jt
1uO61+oSMZWm2unIyyZ3ZQZE0q1da++JXqGW7VKJDZbVw4GQyCtDji/cgrfFnopB
tnVd5ASYgCpXEgB+aGP5Cu00isU47A==
Server certificate
subject=/C=US/O=Docker/OU=Docker/L=San Francisco/CN=test.example.com
issuer=/C=US/O=Docker/OU=Docker/L=San Francisco/CN=test.example.com
2) 复制公钥到文件/etc/docker/certs.d/test.example.com:443/ca.crt
3) 验证该CA证书
cd /etc/docker/certs.d/test.example.com:443
curl -u user:password --cacert ca.crt https://test.example.com:443
4) 即可成功登录镜像服务器
docker login -u user -p password -e mailbox test.example.com:443