docker - 如何在 Apache httpd 后面公开 Docker-Registry?
问题描述
我正在使用以下docker-compose.yml文件运行私有 docker-registry v2:
registry:
restart: always
image: registry:2
ports:
- 5000:5000
environment:
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/server-cert.pem
REGISTRY_HTTP_TLS_KEY: /certs/server-key.pem
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
volumes:
- /data/docker-registry:/var/lib/registry
- /certs/docker-registry:/certs
- /auth/docker-registry:/auth
我可以在http://localhost:5000本地登录(SSH,Jenkins,...) 。
现在我想用 Apache httpd 公开这个注册表。我在 CentOS 7 上运行以下版本的 httpd:
[root@dev-machine conf.d]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Jun 27 2018 13:48:59
这是我的vhosts.conf:
<VirtualHost *:443>
ServerName dev-machine.com
ServerAlias www.dev-machine.com
ErrorLog logs/dev-machine.com-error_log
CustomLog logs/dev-machine.com-access_log common
SSLEngine on
SSLCertificateFile /certs/docker-registry/server-cert.pem
SSLCertificateKeyFile /certs/docker-registry/server-key.pem
Header set Host "dev-machine.com"
Header set "Docker-Distribution-Api-Version" "registry/2.0"
RequestHeader set X-Forwarded-Proto "https"
ProxyRequests off
ProxyPreserveHost on
ProxyPass /registry http://127.0.0.1:5000/
ProxyPassReverse /registry http://127.0.0.1:5000/
<Location /registry>
Order deny,allow
Allow from all
AuthName "Registry Authentication"
AuthType basic
AuthUserFile "/auth/htpasswd"
Require valid-user
</Location>
</VirtualHost>
我面临的问题是,当我尝试登录注册表时,出现以下错误:
izio@1z10:~$ docker login https://dev-machine.com/registry
Username: user
Password:
Error response from daemon: login attempt to https://dev-machine/v2/ failed with status: 404 Not Found
似乎重定向到 /v2 而不是在 vhosts 中使用分配的 url。此配置有什么遗漏或错误?
解决方案
只需像这样更新您的 httpd.conf
ProxyPass /registry http://127.0.0.1:5000/ v2
ProxyPassReverse /registry http://127.0.0.1:5000/ v2
推荐阅读
- c# - 使用 Intersect 比较 2 个列表,但在第 3 个列表中应包含列表 2 中的匹配 AND 属性
- javascript - 使用 chart.js 堆叠两个 y 轴
- java - 出现错误:尝试在静态方法中构造类时,无法从静态上下文中引用非静态变量 this
- mysql - sql更新where子查询
- python - 有没有办法用 if 语句方法来简化这个列表理解?
- r - 如何在“聚合”之后绘制(带误差线)?
- python - 给定一个字典列表,我怎样才能找到每个键出现在多少个字典中?
- kubernetes - Grafana 仪表板不在 Rancher UI 中显示数据
- html - 页脚覆盖主要内容
- javascript - Squarespace JQuery:特定高度上的侧导航活动类