我目前正在尝试将nexus3配置为docker镜像的私有注册表,其中nginx用作反向代理。在nexus中创建了3个repos,即NexusDockerProxy(docker proxy),NexusDockerHosted(docker hosted,http port:4444)& NexusDockerGroup(docker group,http port:5555)同时添加了托管和代理。
nexus配置了nginx,我们使用自签名证书并将其添加到nginx配置文件中。
server {
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_buffering off;
tcp_nodelay on;
server_tokens off;
client_max_body_size 1G;
listen 80;
server_name server908.int.org.com;
location / {
rewrite ^(.*) https://server908.int.org.com$1 permanent;
}
}
server {
listen 443;
server_name server908.int.org.com;
keepalive_timeout 60;
ssl on;
ssl_certificate /etc/ssl/certs/orgnexus.crt;
ssl_certificate_key /etc/ssl/certs/orgnexus.key;
ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH;
ssl_session_cache shared:TLSSSL:16m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "https";
proxy_pass http://server908.int.org.com:8082;
proxy_read_timeout 90;
}
}
# correlates to your nexus http connector
server {
listen 6666;
server_name server908.int.org.com;
keepalive_timeout 60;
ssl on;
ssl_certificate /etc/ssl/certs/orgnexus.crt;
ssl_certificate_key /etc/ssl/certs/orgnexus.key;
ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH;
ssl_session_cache shared:TLSSSL:16m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
client_max_body_size 1G;
chunked_transfer_encoding on;
location / {
access_log /var/log/nginx/docker.log;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "https";
proxy_pass http://server908.int.org.com:5555;
proxy_read_timeout 90;
}
}
我们在下面的条目中注明了“/ etc / default / docker”文件。
http_proxy=http://x.x.x.x:3128
https_proxy=http://x.x.x.x:3128
登录也很成功
[root@server446 ~]$ docker login -u admin -p admin123 server908.int.org.com:6666
Login Succeeded
搜索&拉动图像也很好。
[test@server446 ~]$ docker search server908.int.org.com:6666/mac
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
org.com server908.int.org.com:6666/crate CrateDB is a distributed SQL database hand... 79 [OK]
org.com server908.int.org.com:6666/maccam912/meanjs MEANJS (not MEANIO) starting point for dev... 27 [OK]
org.com server908.int.org.com:6666/macadmins/puppetmaster Simple puppetmaster based on CentOS 6 25 [OK]
org.com server908.int.org.com:6666/macadmins/bsdpy Apple NetBoot replacement written in Pytho... 18 [OK]
org.com server908.int.org.com:6666/macadmins/reposado Host Apple Software Updates from a Docker ... 12 [OK]
org.com server908.int.org.com:6666/mackerel/mackerel-agent 11 [OK]
org.com server908.int.org.com:6666/macadmins/munkiwebadmin This Docker container runs MunkiWebAdmin. ... 8 [OK]
org.com server908.int.org.com:6666/macadmins/postgres Postgres that accepts remote connections b... 8 [OK]
org.com server908.int.org.com:6666/macropin/strider Possibly the best `Dockerfile` for Strider-CD 8 [OK]
org.com server908.int.org.com:6666/mace/openvpn-as OpenVPN Access-Server with WebUI 7 [OK]
org.com server908.int.org.com:6666/frolvlad/alpine-python-machinelearning Small Docker image with Python Machine Lea... 6 [OK]
org.com server908.int.org.com:6666/macadmins/munkireport-php Docker autobuild repository for https://re... 6 [OK]
org.com server908.int.org.com:6666/mace/qbittorrent qBittorrent build from source 6 [OK]
org.com server908.int.org.com:6666/macropin/sshd (deprecated) Use docker.io/panubo/sshd 5 [OK]
org.com server908.int.org.com:6666/macadmins/macnamer 4 [OK]
org.com server908.int.org.com:6666/macadmins/puppetmaster-whdcli Puppetmaster + WHDCLI for autosigning base... 4 [OK]
org.com server908.int.org.com:6666/macadmins/sal An image that runs [Sal](https://github.co... 4 [OK]
org.com server908.int.org.com:6666/macropin/roundcube Docker container for Roundcube webmail 4 [OK]
org.com server908.int.org.com:6666/uetchy/machinelearning Dockerfile for scientists studying Machine... 4 [OK]
org.com server908.int.org.com:6666/clearlinux/machine-learning Machine Learning Container 3 [OK]
org.com server908.int.org.com:6666/hartator/wayback-machine-downloader Download an entire archive from the Waybac... 3 [OK]
org.com server908.int.org.com:6666/macadmins/whd Docker container for SolarWinds WebHelpDesk 3 [OK]
org.com server908.int.org.com:6666/macinv/gunicorn-example A simple Gunicorn example 2 [OK]
org.com server908.int.org.com:6666/macropin/mailman Mailman all in one container 2 [OK]
org.com server908.int.org.com:6666/spacemacs/emacs25 Spacemacs running on Emacs 25. 2 [OK]
[test@server446 ~]$ docker pull server908.int.org.com:6666/macadmins/puppetmaster
Using default tag: latest
Trying to pull repository server908.int.org.com:6666/macadmins/puppetmaster ...
sha256:bf7a53a0ddb6cd0371cfec3fe6131347b5a3712c2cf282400c979ed254a38f67: Pulling from server908.int.org.com:6666/macadmins/puppetmaster
0d399614d56a: Pull complete
75e4c6031170: Pull complete
12a00ed15a39: Pull complete
6fb754ec65e3: Pull complete
9b6cf7664f02: Pull complete
07db30a930a5: Pull complete
ccdd2cf9b303: Pull complete
820dfdfc6db7: Pull complete
78c5dec8ba5d: Pull complete
Digest: sha256:bf7a53a0ddb6cd0371cfec3fe6131347b5a3712c2cf282400c979ed254a38f67
Status: Downloaded newer image for server908.int.org.com:6666/macadmins/puppetmaster:latest
但在推送图像时,我们会得到404错误,如下所示。
[test@server446 ~]$ docker push server908.int.org.com:6666/maven:1
The push refers to a repository [server908.int.org.com:6666/maven]
701925f78142: Layer already exists
78bb4fee972f: Layer already exists
e1300844f726: Layer already exists
bfee0515af91: Preparing
2afcf4c557eb: Preparing
72cfa243711c: Waiting
9bf603e17b04: Waiting
70b22baddf90: Waiting
596ecbaf3ba4: Waiting
445ed6ee6867: Waiting
c59fa6cbcbd9: Waiting
8d4d1ab5ff74: Waiting
error parsing HTTP 404 response body: invalid character '<' looking for beginning of value:
我真的想让它发挥作用但现在仍然坚持这最后一步。任何帮助Docker推动工作的帮助都非常有用,谢谢。
答案 0 :(得分:0)
错误error parsing HTTP 404 response body...
是典型的关系,当您只能推送到托管存储库时,尝试告诉您推送到组或代理存储库。
据我所知,这种解释可能合适:
使用nginx配置
server {
listen 6666;
server_name server908.int.org.com;
...
proxy_pass http://server908.int.org.com:5555;
proxy_read_timeout 90;
...
}
然后您将推送到该代理:
docker push server908.int.org.com:6666/maven:1
您最终将被推送到server908.int.org.com:5555。
使用上面的Nexus配置
在联系中创建了3个存储库,分别是NexusDockerProxy(docker代理),NexusDockerHosted(docker托管,http端口:4444)和NexusDockerGroup(docker组,http端口:5555),同时添加了托管和代理
您正在加入Docker组。我认为这就是引发上述错误的原因。
将您的nginx代理配置为转发到4444而不是5555,您应该可以推送。
侧注::这使得尽管有两个终结点(一个用于“从组中读取”)和一个推送到Nexus很有必要。
因此,请在nginx配置中设置两个端点(一个代理到5555,一个代理4444)。从您的注册表中提取所有Dockerfile中的4444代理。仅在推送时才使用代理到5555。
所以我建议这样可以解决问题:
# Proxy 1, the "pull" proxy. Use this when pulling and in your Dockerfiles/docker-compose files
server {
listen 6666;
server_name server908.int.org.com;
[...ssl config and everything else...]
location / {
access_log /var/log/nginx/docker-pull.log;
[...header config and other things...]
proxy_pass http://server908.int.org.com:5555;
proxy_read_timeout 90;
}
}
# Proxy 2, the "push" proxy. Use this endpoint ONLY when pushing images to Nexus.
server {
listen 7777;
server_name server908.int.org.com;
[...ssl config and everything else...]
location / {
access_log /var/log/nginx/docker-push.log;
[...header config and other things...]
proxy_pass http://server908.int.org.com:4444;
proxy_read_timeout 90;
}
}
现在我不是Nexus专家,但这可以解决您的问题。我不确定Nexus是否打算通过一个端点(通过一个端口进行组AND托管Docker存储库)来实现此目的,但是我记得当初将这两个端点设置为一个端点,用于推动一个端点进行拉取。
希望有帮助!