Docker本地registry:推送失败

我试图build立一个本地dockerregistry,但是当我尝试将图像推送到它时遇到麻烦。 我也打开了一个github的问题: https : //github.com/docker/docker/issues/12405

环境

操作系统:CentOS 6.6

内核:2.6.32-504.12.2.el6.x86_64

Docker版本:

$ sudo docker version Client version: 1.5.0 Client API version: 1.17 Go version (client): go1.4.1 

我在公司代理( http:// domain \ username:password @ proxy:port)后面。

问题

我用这个命令启动Docker守护进程:

 sudo docker -d --insecure-registry 127.0.0.1:49500& 

我已经从docker-registry github下载了config_sample.yml文件,将其重命名为registry_config.yml,并且修改了本地风格的“storage_path”(为了指向我想要安装卷的所选目录) :

 local: &local <<: *common storage: local storage_path: /image 

要启动registry(版本0.9.1),我在terminal中打开另一个选项卡,并使用该命令:

 sudo docker run -t -i -p 127.0.0.1:49500:5000 -v $HOME/localRegistry/image:/image -e DOCKER_REGISTRY_CONFIG=$HOME/localRegistry/registry_config.yml --name registry registry /bin/bash 

回到第一个terminal标签,然后我尝试将一个随机图像推送到本地registry,这是我得到一些错误的地方:

 $sudo docker push 127.0.0.1:49500/centos:7 INFO[1215] POST /v1.17/images/127.0.0.1:49500/centos/push?tag=7 INFO[1215] +job push(127.0.0.1:49500/centos) INFO[1215] +job resolve_repository(127.0.0.1:49500/centos) INFO[1215] -job resolve_repository(127.0.0.1:49500/centos) = OK (0) invalid registry endpoint "http://127.0.0.1:49500/v0/". HTTPS attempt: unable to ping registry endpoint https://127.0.0.1:49500/v0/ v2 ping attempt failed with error: Get https://127.0.0.1:49500/v2/: read tcp 127.0.0.1:49500: connection reset by peer v1 ping attempt failed with error: Get https://127.0.0.1:49500/v1/_ping: read tcp 127.0.0.1:49500: connection reset by peer. HTTP attempt: unable to ping registry endpoint http://127.0.0.1:49500/v0/ v2 ping attempt failed with error: Get http://127.0.0.1:49500/v2/: read tcp 127.0.0.1:49500: connection reset by peer v1 ping attempt failed with error: Get http://127.0.0.1:49500/v1/_ping: read tcp 127.0.0.1:49500: connection reset by peer INFO[1215] -job push(127.0.0.1:49500/centos) = ERR (1) ERRO[1215] Handler for POST /images/{name:.*}/push returned error: v1 ping attempt failed with error: Get http://127.0.0.1:49500/v1/_ping: read tcp 127.0.0.1:49500: connection reset by peer ERRO[1215] HTTP Error: statusCode=500 v1 ping attempt failed with error: Get http://127.0.0.1:49500/v1/_ping: read tcp 127.0.0.1:49500: connection reset by peer FATA[0000] Error: v1 ping attempt failed with error: Get http://127.0.0.1:49500/v1/_ping: read tcp 127.0.0.1:49500: connection reset by peer 

问我是否想要一些更具体的细节。 感谢您的关注 :)

UPDATE

我没有注意到,但是因为我昨天从Docker 1.4.1升级到了1.5.0,似乎docker无法通过代理到达集线器(sudo dockersearch失败)。 我通过导出HTTP_PROXY和HTTPS_PROXY环境variables,以及使用sudo -E启动守护进程来解决这个问题。

然后,正如SGer指出的,我没有把我的configuration文件扔进registry容器。 因此,registry无法访问configuration。 我通过将configuration文件移动到其自己的目录中,并通过在运行registry容器时将该目录挂载为卷来改变这种情况。 新的运行命令:

 sudo docker run -t -i -p 127.0.0.1:49500:5000 -v $HOME/localRegistry/image:/image -v $HOME/localRegistry/configDir:/configDir -e DOCKER_REGISTRY_CONFIG=configDir/config.yml --name registry registry /bin/bash 

这两个修改后,我再次testing,这次运行docker守护进程与-D选项。 这里是输出(分成3部分):

https://gist.github.com/ekeryelleven/9714312c45b7ff21ce2a

我启动了registry容器(从另一个terminal选项卡): https : //gist.github.com/ekeryelleven/b9bfa50bfe3221798659

然后,我推了: https : //gist.github.com/ekeryelleven/80f8f1d1dad00b0fbea9

更新2

有人告诉我,它可能链接到https://github.com/docker/docker/issues/9315

我试图重现:

 $ wget -O- --post-data='' 'http://127.0.0.1:49500/images' --2015-04-16 11:01:42-- http://127.0.0.1:49500/images Resolving <proxy>... <ip> Connecting to <proxy>|<ip>|:<port>... connected. Proxy request sent, awaiting response... 504 Gateway Timeout 2015-04-16 11:01:42 ERROR 504: Gateway Timeout. 

所以我想也许代理搞乱了东西,当我试图到达本地registry,所以我再次运行我的第一次testing没有设置docker守护进程的任何代理configuration(没有HTTP_PROXY和HTTPS_PROXYvariables,没有sudo -E)。 输出(3部分):

http://pastebin.com/raw.php?i=XaJaSsWk

启动registry容器: http : //pastebin.com/raw.php?i=1tux468H

推: http : //pastebin.com/raw.php? i= LsvNfdQf

不是一个真正的答案,但我升级到了Docker 1.6和Registry 2.0,问题消失了。