我试图按照本指南创build一个私人的Dockerregistry。 我已经下载并标记了一个Ubuntu映像,并创build了一个registry容器,现在我打算把它推到我的registry中,但是当我调用sudo docker push localhost:6000/Ubuntu我得到以下输出:
The push refers to a repository [localhost:6000/ubuntu] Put http://localhost:6000/v1/repositories/ubuntu/: http: can't write HTTP request on broken connection
所有我已经能够find的是,“不能写HTTP请求”的错误是一个Go错误,但不幸的是,我一直无法find任何有关我如何可以在Docker中解决它。 我也试图findDocker命令的日志,所以我可以尝试获取有关该问题的更多详细信息,但似乎日志只适用于容器,而不是在容器上运行此日志。
我怎样才能解决这个错误?
UPDATE
我只是在没有任何改变的情况下再次运行该命令并得到了一个不同的错
Put http://localhost:6000/v1/repositories/ubuntu/: read tcp [::1]:33417->[::1]:6000: read: connection reset by peer
UPDATE2
再一次,没有改变,现在得到:
Put http://localhost:6000/v1/repositories/ubuntu/: EOF
UPDATE3
在弄乱了一下后,我发现我试图推送到我的registry的图像确实出现在我的泊坞窗图像列表中,但是我似乎无法将其拉下。
UPDATE4
在搞乱之后,似乎分配给我的私有registry的端口只能侦听IPV6,而不是IPV4。 根据这个 git线程, netstat -ntlp好像只能监听IPV6是正常的,但是在运行telnet localhost , netstat -ntlp和iptables -t nat -nxvL ,我仍然没有看到任何东西正在监听127.0 .0.1:6000,这是我的registry(它只是作为一个容器运行)的端口应分配给。 相反,它似乎在聆听::: 1:6000。
另外,因为它被要求,因为我应该列出它,无论如何:
jfarzan@devstack01:~$ sudo docker version Client: Version: 1.10.3 API version: 1.22 Go version: go1.5.3 Git commit: 20f81dd Built: Thu Mar 10 15:54:52 2016 OS/Arch: linux/amd64 Server: Version: 1.10.3 API version: 1.22 Go version: go1.5.3 Git commit: 20f81dd Built: Thu Mar 10 15:54:52 2016 OS/Arch: linux/amd64
UPDATE5
registry容器的日志:
time="2016-04-04T18:34:22Z" level=warning msg="No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable." go.version=go1.5.3 instance.id=25b8dd5a-f154-455b-84ad-3dd61ccf04e0 version=v2.3.1 time="2016-04-04T18:34:22Z" level=info msg="redis not configured" go.version=go1.5.3 instance.id=25b8dd5a-f154-455b-84ad-3dd61ccf04e0 version=v2.3.1 time="2016-04-04T18:34:22Z" level=info msg="Starting upload purge in 58m0s" go.version=go1.5.3 instance.id=25b8dd5a-f154-455b-84ad-3dd61ccf04e0 version=v2.3.1 time="2016-04-04T18:34:22Z" level=info msg="using inmemory blob descriptor cache" go.version=go1.5.3 instance.id=25b8dd5a-f154-455b-84ad-3dd61ccf04e0 version=v2.3.1 time="2016-04-04T18:34:22Z" level=info msg="listening on [::]:5000" go.version=go1.5.3 instance.id=25b8dd5a-f154-455b-84ad-3dd61ccf04e0 version=v2.3.1 time="2016-04-04T19:32:22Z" level=info msg="PurgeUploads starting: olderThan=2016-03-28 19:32:22.890256531 +0000 UTC, actuallyDelete=true" time="2016-04-04T19:32:22Z" level=info msg="Purge uploads finished. Num deleted=0, num errors=1" time="2016-04-04T19:32:22Z" level=info msg="Starting upload purge in 24h0m0s" go.version=go1.5.3 instance.id=25b8dd5a-f154-455b-84ad-3dd61ccf04e0 version=v2.3.1 time="2016-04-05T13:54:59Z" level=warning msg="No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable." go.version=go1.5.3 instance.id=90882341-a150-4384-9434-b091aacdd68b version=v2.3.1 time="2016-04-05T13:54:59Z" level=info msg="redis not configured" go.version=go1.5.3 instance.id=90882341-a150-4384-9434-b091aacdd68b version=v2.3.1 time="2016-04-05T13:54:59Z" level=info msg="Starting upload purge in 59m0s" go.version=go1.5.3 instance.id=90882341-a150-4384-9434-b091aacdd68b version=v2.3.1 time="2016-04-05T13:54:59Z" level=info msg="using inmemory blob descriptor cache" go.version=go1.5.3 instance.id=90882341-a150-4384-9434-b091aacdd68b version=v2.3.1 time="2016-04-05T13:54:59Z" level=info msg="listening on [::]:5000" go.version=go1.5.3 instance.id=90882341-a150-4384-9434-b091aacdd68b version=v2.3.1 time="2016-04-05T14:53:59Z" level=info msg="PurgeUploads starting: olderThan=2016-03-29 14:53:59.133142744 +0000 UTC, actuallyDelete=true" time="2016-04-05T14:53:59Z" level=info msg="Purge uploads finished. Num deleted=0, num errors=1" time="2016-04-05T14:53:59Z" level=info msg="Starting upload purge in 24h0m0s" go.version=go1.5.3 instance.id=90882341-a150-4384-9434-b091aacdd68b version=v2.3.1
当我尝试将映像推送到我的registry时,Docker守护进程的debugging日志:
DEBU[0037] Calling POST /v1.22/images/localhost:6000/hello-world/push DEBU[0037] POST /v1.22/images/localhost:6000/hello-world/push?tag= DEBU[0037] Trying to push localhost:6000/hello-world to https://localhost:6000 v2 DEBU[0037] Error getting v2 registry: Get https://localhost:6000/v2/: read tcp [::1]:33560->[::1]:6000: read: connection reset by peer DEBU[0037] Trying to push localhost:6000/hello-world to http://localhost:6000 v2 DEBU[0037] Error getting v2 registry: Get http://localhost:6000/v2/: read tcp [::1]:33562->[::1]:6000: read: connection reset by peer DEBU[0037] Trying to push localhost:6000/hello-world to https://localhost:6000 v1 DEBU[0037] attempting v2 ping for registry endpoint https://localhost:6000/v2/ DEBU[0037] attempting v1 ping for registry endpoint https://localhost:6000/v1/ DEBU[0037] Trying to push localhost:6000/hello-world to http://localhost:6000 v1 DEBU[0037] Image list: [0xc820aa3840 0xc820704500] DEBU[0037] Tags by image: map[sha256:690ed74de00f99a7d00a98a5ad855ac4febd66412be132438f9b8dbd300a937d:[latest]] DEBU[0037] Pushing ID: b652ec3a27e758f30de4742156b5d096bb19c82f2dc836e96e430323ba166ffe with Tag: DEBU[0037] Pushing ID: 690ed74de00f99a7d00a98a5ad855ac4febd66412be132438f9b8dbd300a937d with Tag: latest DEBU[0037] [registry] PUT http://localhost:6000/v1/repositories/hello-world/ DEBU[0037] Image list pushed to index: [{"id":"b652ec3a27e758f30de4742156b5d096bb19c82f2dc836e96e430323ba166ffe"},{"id":"690ed74de00f99a7d00a98a5ad855ac4febd66412be132438f9b8dbd300a937d","Tag":"latest"}] DEBU[0037] Not continuing with error: Put http://localhost:6000/v1/repositories/hello-world/: EOF
registry日志最后说错误发生了,但是从日志的其余部分我不能真正辨别错误是什么。 我甚至把日志分成标准输出和标准错误,没有什么是stderr。
另外,我已经确认registry正在侦听ipv4。 运行nc -l -4 6000返回Address already in use 。 至less,我想我已经证实了。 ipv4地址仍然不会显示与netstat 。
UPDATE6
使用docker run -d -p 127.0.0.1:8000:8000显式指定一个ipv4端口,此端口显示为在netstat中侦听。 仍然得到相同的错误。 Docker日志有点不同:
time="2016-04-07T15:19:31Z" level=warning msg="No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable." go.version=go1.5.3 instance.id=6391e3dc-6644-4a45-8e8b-a08c8ff798a6 version=v2.3.1 time="2016-04-07T15:19:31Z" level=info msg="redis not configured" go.version=go1.5.3 instance.id=6391e3dc-6644-4a45-8e8b-a08c8ff798a6 version=v2.3.1 time="2016-04-07T15:19:31Z" level=info msg="Starting upload purge in 1m0s" go.version=go1.5.3 instance.id=6391e3dc-6644-4a45-8e8b-a08c8ff798a6 version=v2.3.1 time="2016-04-07T15:19:31Z" level=info msg="using inmemory blob descriptor cache" go.version=go1.5.3 instance.id=6391e3dc-6644-4a45-8e8b-a08c8ff798a6 version=v2.3.1 time="2016-04-07T15:19:31Z" level=info msg="listening on [::]:5000" go.version=go1.5.3 instance.id=6391e3dc-6644-4a45-8e8b-a08c8ff798a6 version=v2.3.1 time="2016-04-07T15:20:31Z" level=info msg="PurgeUploads starting: olderThan=2016-03-31 15:20:31.061864096 +0000 UTC, actuallyDelete=true" time="2016-04-07T15:20:31Z" level=info msg="Purge uploads finished. Num deleted=0, num errors=1" time="2016-04-07T15:20:31Z" level=info msg="Starting upload purge in 24h0m0s" go.version=go1.5.3 instance.id=6391e3dc-6644-4a45-8e8b-a08c8ff798a6 version=v2.3.1
“redis not configured”消息是唯一可能成为问题的东西。 去看看它。 真的,真的很感谢任何额外的见解。
我正在写这个,因为我在这之前花了几个小时才终于破解它。
我的情况:我正在Fedora 25上运行一个docker版本17,并尝试使用自定义configuration文件运行registry,并获得与上面相同的对等重置消息。 这似乎是由于不安全的HTTP连接被重置而发生的,因此我发现有人告诉我在/etc/sysconfig/docker添加DOCKER_OPTS="--insecure-registry localhost:6000 127.0.0.1:6000"选项/etc/sysconfig/docker和/etc/default/docker文件,然后重新启动docker服务。 这并没有解决这个问题,但( 这是官方文档)。
最后的诀窍是使用docker撰写镜像来运行registry。 我遵循digitalocean指南中给出的步骤,它基本上引导您使用docker-compose来设置registry,然后使用nginx设置SSL,如果在本地服务器上完成,将会执行此操作。
但事实certificate,我所需要做的只是步骤2,即设置docker-compose.yml ,并启动registry,瞧! 推现在工作。
解决了这个问题:
不得不运行docker run -d -p 127.0.0.1:6000:5000 。 不使用本地主机确保ipv4被使用(我敢肯定,它被用于其他方式,但至less现在它显示在netstat),容器监听他们的端口5000,所以它不工作。