【问题标题】:Status 405 - docker - artifactory状态 405 - 码头工人 - 神器
【发布时间】:2019-06-12 22:45:53
【问题描述】:

将图像推送到 docker artifactory 时出现以下错误:
v1:

Error: Status 405 trying to push repository abc-docker-local: "{\n  \"errors\" : [ {\n    \"status\" : 405,\n    \"message\" : \"Method Not Allowed\"\n  } ]\n}"

我使用 nginx。我的配置文件如下所示:

server_name localserver;
rewrite ^  remoteserver/artifactory/api/docker/abc-docker-local/v1 redirect;
if ($http_x_forwarded_proto = '') {
    set $http_x_forwarded_proto  $scheme;
}

location / {
        proxy_read_timeout  900;
        proxy_pass_header   Server;
        proxy_cookie_path ~*^/.* /;
        proxy_pass          http://remoteserver:9081/artifactory/api/docker/abc-docker-local/v1;
        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;
}

在 Artifactory 中,我将 repo 设置为 v1。我还用v2 进行了测试,但没有返回任何端点。 v2 的确切错误是:

Index response didn't contain any endpoints

提前致谢

【问题讨论】:

  • 您能指定您使用的 Artifactory 和 docker 客户端版本吗?
  • docker 版本客户端:版本:1.8.2-el7 API 版本:1.20 包版本:docker-1.8.2-10.el7.x86_64 Go 版本:go1.4.2 内置:OS/Arch:linux /amd64 服务器:版本:1.8.2-el7 API 版本:1.20 包版本:Go 版本:go1.4.2 内置:OS/Arch:linux/amd64 两者都设置为使用 api v2 Artifactory 前端显示:您正在运行 Artifactory 版本4.2.2 谢谢!
  • 在这两个版本的最后几个版本中,api 发生了很多变化 - 您可以尝试使用 docker 1.10 和 Artifactory 4.7 吗?
  • 我在设置 Artifactory 4.2.2 方面付出了很多努力你知道与 Artifactory 4.2.2 一起使用的 Docker 版本是什么吗? (如果有)
  • Docker 1.8 应该可以工作-在我看来,您的 nginx 配置很可能有问题...升级到最新的 Artifactory 不会给您带来任何特定问题(或风险),但您会得到reverse proxy snippet 功能并为自己省去所有麻烦。

标签: nginx docker artifactory


【解决方案1】:

如果结果为空白,则您一定没有插入所有必需的配置 - 这是我的沙箱中的一个示例:

无论如何,这是我使用的 Artifactory 生成的配置,它适用于安装在远程 Ubuntu 机器上的 Docker 1.10(但也适用于 Docker 1.8 和 1.9),而我的 Artifactory 沙箱是我的机器。

请注意我拥有的证书位置不常见 (certs\myCert.cert) 因此将其更改为您的 SSL 证书所在的位置,并且我正在使用端口 44414442 分别用于 V1V2

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    ## add ssl entries when https has been set in config
    ssl_certificate      certs\myCert.cert;
    ssl_certificate_key  certs\myCert.cert;
    ssl_session_cache shared:SSL:1m;
    ssl_prefer_server_ciphers   on;
    ## server configuration
    server {
        listen 443 ssl;
        listen 9091 ;

        server_name localhost;
        if ($http_x_forwarded_proto = '') {
            set $http_x_forwarded_proto  $scheme;
        }
        ## Application specific logs
        ## access_log /var/log/nginx/localhost-access.log timing;
        ## error_log /var/log/nginx/localhost-error.log;
        rewrite ^/$ /artifactory/webapp/ redirect;
        rewrite ^/artifactory/?(/webapp)?$ /artifactory/webapp/ redirect;
        location /artifactory/ {
        proxy_read_timeout  900;
        proxy_pass_header   Server;
        proxy_cookie_path ~*^/.* /;
        proxy_pass         http://localhost:8080/artifactory/;
        proxy_set_header   X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
        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;
        }
    }

    ## server configuration
    server {
        listen 4441 ssl;


        server_name localhost;
        if ($http_x_forwarded_proto = '') {
            set $http_x_forwarded_proto  $scheme;
        }
        ## Application specific logs
        ## access_log /var/log/nginx/localhost-access.log timing;
        ## error_log /var/log/nginx/localhost-error.log;
        rewrite ^/(v1|v2)/(.*) /artifactory/api/docker/docker-local-v1/$1/$2;
        client_max_body_size 0;
        chunked_transfer_encoding on;
        location /artifactory/ {
        proxy_read_timeout  900;
        proxy_pass_header   Server;
        proxy_cookie_path ~*^/.* /;
        proxy_pass         http://localhost:8080/artifactory/;
        proxy_set_header   X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
        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;
        }
    }

    ## server configuration
    server {
        listen 4442 ssl;


        server_name localhost;
        if ($http_x_forwarded_proto = '') {
            set $http_x_forwarded_proto  $scheme;
        }
        ## Application specific logs
        ## access_log /var/log/nginx/localhost-access.log timing;
        ## error_log /var/log/nginx/localhost-error.log;
        rewrite ^/(v1|v2)/(.*) /artifactory/api/docker/docker-local-v2/$1/$2;
        client_max_body_size 0;
        chunked_transfer_encoding on;
        location /artifactory/ {
        proxy_read_timeout  900;
        proxy_pass_header   Server;
        proxy_cookie_path ~*^/.* /;
        proxy_pass         http://localhost:8080/artifactory/;
        proxy_set_header   X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
        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;
        }
    }
}

【讨论】:

  • 所以你有artifactory和nginx在同一台机器上?相比之下,我在一台机器上有 nginx 和 docker,在另一台机器上有 artifactory
  • 我将设置更改为:内部端口 8081,外部端口 8443,docker 注册表绑定到端口 80 并且 API 是 v2(v1 未显示在设置页面中)我收到此错误:** ****************************************************** ************************************ “错误:状态 400 试图推送存储库 tomcat:“{\n \”错误\" : [ {\n \"status\" : 400,\n \"message\" : \"不支持的 docker v1 存储库请求'removed'\"\n } ]\n}" ****** ****************************************************** ***************************** docker 和 nginx 在同一个 VM 中。artifactory 在另一个 VM 中
  • 更新到 docker 1.9.1 后,我收到以下回复:“未知:不允许的方法”完整版本是 docker-1.9.1-25.el7.x86_64
  • 如果没有您的日志(启用了特定的调试条目),恐怕很难判断,如果您正确使用了我的模板。我建议你联系 support@jfrog.com,对我来说似乎是你的配置有问题。
  • 我收到了来自 support@jfrog.com 的帮助问题是我使用了 docker 客户端自动重定向到 https 的端口 80,并且由于我没有适当的安全证书,因此失败了。我改变了端口并像魅力一样工作。
猜你喜欢
  • 2016-07-09
  • 2017-02-01
  • 2016-01-18
  • 1970-01-01
  • 1970-01-01
  • 2022-01-18
  • 2012-04-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多