无法推送Docker镜像到Artifactory

3

我将Artifactory设置为Docker注册表,并试图将镜像推送到其中。

docker push nginxLoadBalancer.mycompany.com/repo_name:image_name

以下是错误信息:

The push refers to a repository [ nginxLoadBalancer.mycompany.com/repo_name] (len: 1)
unable to ping registry endpoint https://nginxLoadBalancer.mycompany.com/v0/
v2 ping attempt failed with error: Get https://nginxLoadBalancer.mycompany.com/v2/: Bad Request
 v1 ping attempt failed with error: Get https://nginxLoadBalancer.mycompany.com/v1/_ping: Bad Request

这是我的 Nginx 配置文件

upstream artifactory_lb {
                server mNginxLb.mycompany.com:8081;
                server mNginxLb.mycompany.com backup;
        }

        log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name  to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';

        server {
                listen 80;
                listen 443 ssl;

                ssl_certificate  /etc/nginx/ssl/my-certs/myCert.pem;
                ssl_certificate_key /etc/nginx/ssl/my-certs/myserver.key;
                client_max_body_size 2048M;
                location / {
                        proxy_set_header Host $host:$server_port;
                        proxy_pass http://artifactory_lb;
                        proxy_read_timeout 90;
                }
                access_log /var/log/nginx/access.log upstreamlog;
                location /basic_status {
                        stub_status on;
                        allow all;
                        }
        }

        # Server configuration

        server {
            listen 2222 ssl;

            server_name mNginxLb.mycompany.com;
            if ($http_x_forwarded_proto = '') {
                set $http_x_forwarded_proto  $scheme;
            }

            rewrite ^/(v1|v2)/(.*) /api/docker/my_local_repo_key/$1/$2;
            client_max_body_size 0;
            chunked_transfer_encoding on;
            location / {
            proxy_read_timeout  900;
            proxy_pass_header   Server;
            proxy_cookie_path ~*^/.* /;
            proxy_pass         http://artifactory_lb;
            proxy_set_header   X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host;
            proxy_set_header    X-Forwarded-Port  $server_port;
            proxy_set_header    X-Forwarded-Proto $http_x_forwarded_proto;
            proxy_set_header    Host              $http_host;
            proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
            }
        }

没有在nginx错误日志中发现错误。可能出了什么问题? 我验证了SSL验证与设置一致,工作正常。在推送镜像之前,我需要设置身份验证吗? 我还验证了artifactory服务器正在侦听端口2222。
更新,
我将以下内容添加到nginx配置中。
  location /v1 {
            proxy_pass http://myNginxLb.company.com:8080/artifactory/api/docker/docker-local/v1;
        }

现在,当尝试将内容推送到仓库时,会出现405 - 不允许的错误。


2
你使用的Artifactory版本是什么?我们在将docker升级到1.8时遇到了这个问题,因为旧版本的Artifactory还不支持V2注册表。 - Kevan Ahlquist
Artifactory的版本支持v2,并且给我选择v1或v2的选项。 - user_mda
我不确定重写和新位置的配置是否能很好地协同工作。尝试移除重写。 - Dror Bereznitsky
1个回答

1
我通过删除位置为 /v1 的配置并将代理传递更改为指向上游服务器来解决了这个问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接