Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker local registry : push fails

I'm trying to setup a local docker registry, but I get in troubles when trying to push images to it. I opened a github issue too: https://github.com/docker/docker/issues/12405

ENVIRONMENT

OS: CentOS 6.6

Kernel: 2.6.32-504.12.2.el6.x86_64

Docker version:

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

I'm behind a corporate proxy (http://domain\username:password@proxy:port).

PROBLEM

I'm launching the Docker daemon with this command:

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

I've downloaded the config_sample.yml file from docker-registry github, renamed it to registry_config.yml, and just modified the "storage_path" in the local flavor (in order to point to a chosen directory where I want to mount a volume):

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

To start the registry (version 0.9.1), I open another tab in my terminal and I use that command:

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

Back on the 1st terminal tab, I then try to push a random image into the local registry, and this is where I get some errors:

$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

Ask me if you want some more specific details. Thanks for your attention :)

UPDATE

I had not noticed, but since I've upgraded from Docker 1.4.1 to 1.5.0 yesterday, it seems like docker wasn't able to reach the hub through the proxy (sudo docker search was failing). I fixed that by exporting HTTP_PROXY and HTTPS_PROXY environement variables, and by launching the daemon with sudo -E.

Then, as SGer pointed out, I wasn't throwing my config file into the registry container. Thus, the registry couldn't access the config. I changed that by moving the config file into its own directory, and by mounting that directory as a volume when running the registry container. The new running command:

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

After those 2 modifications, I tested again, running docker daemon with -D option this time. Here is the output (split into 3 parts):

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

I launched the registry container (from another terminal tab): https://gist.github.com/ekeryelleven/b9bfa50bfe3221798659

Then, I pushed: https://gist.github.com/ekeryelleven/80f8f1d1dad00b0fbea9

UPDATE 2

Somebody told me it was possibly linked to https://github.com/docker/docker/issues/9315

I tried to reproduce:

$ 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.

So I thought maybe the proxy was messing up things when I'm trying to reach local registry, so I ran again my 1st test without setting any proxy config for the docker daemon (no HTTP_PROXY and HTTPS_PROXY variables, no sudo -E). Output (3 parts):

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

Launching the registry container: http://pastebin.com/raw.php?i=1tux468H

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

like image 640
Elouan Keryell-Even Avatar asked Apr 15 '15 16:04

Elouan Keryell-Even


People also ask

Does docker build push to registry?

The built image is then pushed to the Docker Hub registry. You can still use docker push to push pre-built images to repositories with Automated Builds configured. If you have automated tests configured, these run after building but before pushing to the registry.

Why docker push denied requested access to the resource is denied?

Why this error occurs? As the error says requested access to the resource is denied error, you as a docker user do not have the correct rights/permission to run the docker push or any other docker command. Or your docker hub credentials are incorrect.


1 Answers

Not really an answer, but I upgraded to Docker 1.6 and Registry 2.0 and the problem disappeared.

like image 86
Elouan Keryell-Even Avatar answered Oct 02 '22 00:10

Elouan Keryell-Even