我正在设置一个私有 docker 注册表,前面带有 NGINX 进行身份验证。两者都在一个链接的容器中。我使用的 nginx 镜像是jwilder/nginx-proxy。我可以很好地 ping 注册表:
>http zite.com:5000/v1/_ping
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 2
Content-Type: application/json
Date: Thu, 02 Apr 2015 12:13:32 GMT
Expires: -1
Pragma: no-cache
Server: nginx/1.7.11
X-Docker-Registry-Standalone: True
但是推送图像给了我:
FATA[0001] HTTP code 401, Docker will not send auth headers over HTTP
我尝试将注册表标记为不安全但无济于事:
--insecure-registry zite.com:5000
我已经能够在没有 NGINX 的情况下运行这个设置。
我的 NGINX 配置文件是(其中 'dockerregistry' 是链接容器的名称):
upstream dockerregistry {
server dockerregistry:5000;
}
server {
listen 80;
server_name zite.com;
proxy_set_header Host $http_host;
client_max_body_size 0;
location / {
proxy_pass http://dockerregistry;
auth_basic "Docker Registry";
auth_basic_user_file /etc/nginx/dockerregistry_users;
}
location /v1/_ping {
auth_basic off;
proxy_pass http://dockerregistry;
}
}
我想我已经阅读了几乎所有关于此设置的文章,但我无法弄清楚的一件事是,仅 HTTP 访问私有 docker repo 是否完全不可行。有没有可能让它工作?还是我必须使用 SSL 证书?如果是这样,谁知道这个设置的好指南?