Docker注册表--insecure-registry不能正常工作

时间:2016-07-26 05:09:14

标签: ssl docker https

我试图在CentOS 7上运行Docker注册表以供内部使用。

我已经从/usr/lib/systemd/system/docker.service设置了Docker配置,如下所示:

[Service]
.... 
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// --insecure-registry 127.0.0.1:5000
....

然后使用systemctl daemon-reloadsudo service docker start启动了docker守护程序,并使用ps -ef | grep docker选项确认docker正在运行:

root     116221      1  0 13:21 ?        00:00:00 /usr/bin/docker daemon -H fd:// --insecure-registry 127.0.0.1:5000

但是当我尝试使用https连接到注册表时,它失败了。

# Try from the server which the registry is running

curl -X GET https://127.0.0.1:5000/v1/_ping
=> curl: (35) Encountered end of file


# Try from the remote client

curl -X GET https://{registry-server-ip}:5000/v1/_ping
=> curl: (35) Server aborted the SSL handshake

当然,我已成功通过http访问注册表:

curl -X GET http://127.0.0.1:5000/v1/_ping
=> {"host": ["Linux", ...}

供参考,

# docker version
Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:23:11 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:23:11 2016
 OS/Arch:      linux/amd64

我应该查看更多内容?

2 个答案:

答案 0 :(得分:0)

您可以在http但不在https中访问的原因仅仅是因为您将注册表配置为不安全注册表。这意味着,没有启用TLS。您可以在herehere找到有关安全注册表的更多信息。

如果您想使https也有效,您需要准备一个CA,并使用它配置您的注册表。请确保您的CA配置正确。

编辑: 我猜你可能误解了什么" insecure-registry"是。此功能不支持真正的TLS支持,它允许您创建私有注册表,仅支持具有未知CA证书的HTTP或HTTPS。如果您希望HTTPS工作,您有两种选择:使用自签名CA或购买CA. troubleshoot part here可能会对您有所帮助。

EDIT2:要尝试访问HTTP,我按照注册表的官方图片页面上的指南运行一个简单的测试:Run the registry docker container: Quick version

以下是步骤:

  1. 添加不安全选项DOCKER_OPTS="--insecure-registry=127.0.0.1:5000", 然后重启docker service。

  2. $ docker run -p 5000:5000 -v /home/mypc/data:/tmp/registry-dev registry

  3. $ docker tag hello-world 127.0.0.1:5000/hello

  4. $ docker push 127.0.0.1:5000/hello
  5. 输出结果为:

    The push refers to a repository [127.0.0.1:5000/hello]
    
    a02596fdd012: Image successfully pushed 
    
    Pushing tag for rev [c54a2cc56cbb] on {http://127.0.0.1:5000/v1/repositories/hello/tags/latest}
    

    码头推进工作正常。

答案 1 :(得分:0)

您也可以查看此链接:

  

https://docs.docker.com/engine/security/certificates/

它解释了您在docker客户端计算机上存储证书的位置,以便注册表不再被视为不安全的。

相关问题