Docker本地注册表:推送失败

时间:2015-04-15 16:09:39

标签: docker centos6 docker-registry

我正在尝试设置本地docker注册表,但在尝试将图像推送到它时遇到了麻烦。我也开了一个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

要启动注册表(版本0.9.1),我在终端中打开另一个选项卡,然后使用该命令:

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

回到第一个终端选项卡,然后我尝试将随机图像推送到本地注册表,这就是我遇到错误的地方:

$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

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

更新

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

然后,正如SGer指出的那样,我没有将配置文件丢入注册表容器中。因此,注册表无法访问配置。我通过将配置文件移动到其自己的目录中,并通过在运行注册表容器时将该目录作为卷安装来更改它。新的运行命令:

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

经过这两次修改,我再次测试,这次用-D选项运行docker守护进程。这是输出(分为3部分):

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

我启动了注册表容器(来自另一个终端选项卡):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.

所以我想当我试图访问本地注册表时,代理可能搞乱了,所以我再次运行我的第一次测试而没有为docker守护进程设置任何代理配置(没有HTTP_PROXY和HTTPS_PROXY变量,没有sudo -E)。输出(3部分):

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

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

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

1 个答案:

答案 0 :(得分:2)

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

相关问题