大网数据广告活动
服务器运维问答

Pushing to local docker registry gives connection reset error

· 52CE 我爱测

I'm trying to create a private Docker registry by following this guide . I've downloaded and tagged an Ubuntu image and created a registry container and now I intend to push it to my registry, but when I call sudo docker push loc…

问题原文

原帖链接 · jackwise · CC BY-SA 4.0

I'm trying to create a private Docker registry by following this guide. I've downloaded and tagged an Ubuntu image and created a registry container and now I intend to push it to my registry, but when I call sudo docker push localhost:6000/Ubuntu I get the following output:

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

All I've been able to find is that the "can't write HTTP request" error is a Go error, but unfortunately I have not been able to find anything related to how I can resolve it in Docker. I have also tried to find logs for Docker commands so I can try to get more detail on the issue, but it seems like logs are only available for containers, and I'm not running this on a container.

How can I go about resolving this error?

UPDATE

I just ran the command again after changing nothing and got a different error:

Put http://localhost:6000/v1/repositories/ubuntu/: read tcp [::1]:33417->[::1]:6000: read: connection reset by peer

UPDATE2

And again, ran it after changing nothing and am now getting:

Put http://localhost:6000/v1/repositories/ubuntu/: EOF

UPDATE3

After messing around a bit, I've found that the image I tried to push to my registry does appear in my docker images list, but I don't seem to be able to pull it.

UPDATE4

After messing around a bit more, it seems like the port I assigned to my private registry is only listening on IPV6, rather than IPV4. According to this git thread, it is normal for docker to seem like it is only listening on IPV6, but after running telnet localhost, netstat -ntlp, and iptables -t nat -nxvL, I still see no indication that anything is listening on 127.0.0.1:6000, which is the port that my registry (which is just running as a container) should be assigned to. Instead, it seems to be listening on :::1:6000.

Also, because it was requested and because I should have listed it regardless:

user@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 container's logs:

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

Docker daemon's debug logs when I try to push an image to my registry:

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

The registry logs end with saying that an error occurred, but from the rest of the log I can't actually discern what that error was. I even split the log into stdout and stderr and nothing was in stderr.

Also, I've confirmed that the registry is listening on ipv4. Running nc -l -4 6000 returns Address already in use. At least, I think I've confirmed it. The ipv4 addresses still won't show up with netstat.

UPDATE6

Explicitly specified an ipv4 port with docker run -d -p 127.0.0.1:8000:8000, this port shows up as listening in netstat. Still getting the same errors. Docker logs are a bit different though:

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

The "redis not configured" message is the only thing that seems like it could be a problem. Going to look into it. Would really, really appreciate any additional insight.

已采纳解答

原帖链接 · jackwise · CC BY-SA 3.0

Solved the issue:

Had to run with docker run -d -p 127.0.0.1:6000:5000. Not using localhost ensured that ipv4 was used (I'm pretty sure it was used otherwise but at least now it shows up in netstat) and the containers listen on their port 5000, so it did not work otherwise.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0 / CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。