docker登录不使用nexus 3私有注册表

时间:2016-08-25 14:50:06

标签: nginx docker nexus

Nexus UI Config

我在Linux VM上运行Nexus Repository Manager OSS 3.0.1-01 在该VM上,我让nginx将代理http请求保留为https。 我的SSL密钥由可信CA签名 我创建了一个maven存储库,无论何时我都有客户端机器发布它,它都能正常工作。

此外,在此客户端计算机上,当我使用我的docker客户端时,还要执行docker登录。我收到了各种各样的错误。

我正在遵循这些说明https://books.sonatype.com/nexus-book/3.0/reference/docker.html#_accessing_repositories 特别是9.2节,老实说,过去两天我一直无处可去。

我已经阅读了这里提到的所有内容: Trouble connecting to Docker registry stored on Nexus 3 Preview on Azure VM 但是用户解释的这种设置让我很困惑。

对于我们尝试通过将--insecure-registry添加到/etc/default/docker文件来实现不安全设置的设置,根本就不是 一个选项。

为了了解docker注册表的内部工作原因,我试图遵循多个教程,但我还没有能够分片 它在一起。我已经在一定程度上关注了这一点:https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-docker-registry-on-ubuntu-14-04

我在stackoverflow中使用了其他响应来帮助我排除故障 malformed HTTP response with docker private registry (v2) behind an nginx proxy

但老实说,我不能说我发现任何能够直接理解这一点的东西。 NGINX没有报告任何错误日志 在/var/log/nginx/errors.log中,每次我尝试登陆停机时,访问日志都看起来像基本' GETS' docker登录 /var/log/upstart/docker.log报告了我在下面用404错误说明的相同错误。 还在github上关注这个问题,看看是否有任何帮助github com / docker / docker / issues / 8410。任何协助让我能够成功登陆这个私人nexus 3回购的登陆者都会很棒。

现在也许我对我为了让我的docker客户端成功使用这个nexus repo所阅读的所有东西感到困惑,但是我需要设置一个docker(group)repo,那就是我的问题的根源?或者我可以只拥有一个泊坞(托管)回购。因为截至目前我只有一个泊坞(托管)回购。 Nexus文档并没有给我一个印象,即组合回购也需要让事情发挥作用。

最后但并非最不重要的是,我希望我的问题足够具体,我希望你们看到我在这里做了一些努力。我真的试过了!

当我登录时,我使用的是本地管理员用户,使用默认的管理员密码。 首先让我提出问题:

如果我尝试没有端口,我会得到以下内容 -

root:~# docker login box.company.net
Error response from daemon: Login:
<!DOCTYPE html>
<html>
<head>
  <title>404 - Nexus Repository Manager</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

使用4444的HTTP端口,我得到以下

root:~# docker login box.company.net:4444
Error response from daemon: Get https://box.company.net:4444/v1/users/: `http: server gave HTTP response to HTTPS client`

如果我在Nexus UI中将HTTPS添加到4445,那么我运行

root:~# docker login box.company.net:4445
Error response from daemon: Get https://box.company.net:4445/v1/users/: dial tcp x.x.x.x:4445: getsockopt: connection refused

这是我的环境信息:

#cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"

# uname -r
3.19.0-65-generic

# nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

~# docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:22:43 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:22:43 2016
 OS/Arch:      linux/amd64

cat /etc/nginx/conf.d/site.conf

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 box.company.net;
    location / {
          rewrite ^(.*) https://box.company.net$1 permanent;
    }
}

server {
    listen 443;
    server_name box.company.net;
    keepalive_timeout 60;
    ssl on;
    ssl_certificate /etc/nginx/conf.d/net.crt;
    ssl_certificate_key /etc/nginx/conf.d/net.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://x.x.x.x:8081;
      proxy_read_timeout      90;

    }
}

这里有一些基本的卷曲结果以获取更多信息,如果这将有所帮助。

 root:~# curl -v https://box.company.net
* Rebuilt URL to: https://box.company.net
* Hostname was NOT found in DNS cache
*   Trying x.x.x.x...
* Connected to box.company.net (x.x.x.x) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
*        subject: OU=Domain Control Validated; CN=*.company.net
*        start date: 2016-04-01 14:01:38 GMT
*        expire date: 2018-04-14 15:15:04 GMT
*        subjectAltName: box.company.net matched
*        issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
*        SSL certificate verify ok.
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: box.company.net
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.4.6 (Ubuntu) is not blacklisted
< Server: nginx/1.4.6 (Ubuntu)
< Date: Thu, 25 Aug 2016 13:39:14 GMT
< Content-Type: text/html
< Content-Length: 5077
< Connection: keep-alive
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Last-Modified: Thu, 25 Aug 2016 13:39:14 GMT
< Pragma: no-cache
< Cache-Control: post-check=0, pre-check=0
< Expires: 0

任何有助于让docker登录private.registry.net的帮助都非常有用,谢谢。

1 个答案:

答案 0 :(得分:4)

我必须在我的nginx配置中添加一个额外的(服务器)条目,就在前一个条目

的正下方

重新启动nginx

docker客户端,将连接到端口6666,nginx会将流量路由到4444端口

# correlates to your nexus http connector
server {
    listen 6666;
    server_name box.company.net;
    keepalive_timeout 60;
    ssl on;
    ssl_certificate /etc/nginx/conf.d/net.crt;
    ssl_certificate_key /etc/nginx/conf.d/net.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://x.x.x.x:4444;
      proxy_read_timeout      90;

    }
}

然后我可以

docker login -u username -p password box.company.net:6666
docker pull box.company.net:6666/docker-image:tag
docker push box.company.net:6666/docker-image:tag
相关问题