我正在尝试在 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-reload
和 sudo service docker start
启动 docker 守护进程,并确认 docker 正在使用 ps -ef 选项运行| grep 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
我应该多检查什么?
最佳答案
您可以在 http 中访问但不能在 https 中访问的原因仅仅是因为您将注册表配置为不安全的注册表。这意味着,没有启用 TLS。您可以在 here 找到有关安全注册表的更多信息。和 here .
如果你想让 https 也能工作,你需要准备一个 CA,并用它配置你的注册中心。请确保您的 CA 配置正确。
编辑: 我想您可能误解了“不安全注册表”是什么。此功能不启用真正的 TLS 支持,它允许您创建私有(private)注册表,仅支持具有未知 CA 证书的 HTTP 或 HTTPS。如果您希望 HTTPS 有效,您有两种选择:使用自签名 CA 或购买 CA。 troubleshoot part here可能对你有帮助。
EDIT2:为了尝试 HTTP 访问,我按照注册表官方图像页面上的指南运行了一个简单的测试:Run the registry docker container: Quick version
步骤如下:
添加不安全选项
DOCKER_OPTS="--insecure-registry=127.0.0.1:5000"
, 然后重启docker服务。$ docker run -p 5000:5000 -v/home/mypc/data:/tmp/registry-dev 注册表
$ docker tag hello-world 127.0.0.1:5000/hello
$ docker push 127.0.0.1:5000/hello
输出是:
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}
docker push 正在运行。
关于ssl - Docker 注册表 --insecure-registry 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38581414/