title: Docker local registry : push fails
body: <p>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: <a href="https://github.com/docker/docker/issues/12405" rel="nofollow">https://github.com/docker/docker/issues/12405</a></p>
  
  <p><strong>ENVIRONMENT</strong></p>
  
  <p>OS: CentOS 6.6</p>
  
  <p>Kernel: 2.6.32-504.12.2.el6.x86_64</p>
  
  <p>Docker version:</p>
  
  <pre><code>$ sudo docker version
  Client version: 1.5.0
  Client API version: 1.17
  Go version (client): go1.4.1
  </code></pre>
  
  <p>I'm behind a corporate proxy (<a href="http://domain" rel="nofollow">http://domain</a>\username:password@proxy:port).</p>
  
  <p><strong>PROBLEM</strong></p>
  
  <p>I'm launching the Docker daemon with this command:</p>
  
  <pre><code>sudo docker -d --insecure-registry 127.0.0.1:49500&amp;
  </code></pre>
  
  <p>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):</p>
  
  <pre><code>local: &amp;local
  &lt;&lt;: *common
  storage: local
  storage_path: /image
  </code></pre>
  
  <p>To start the registry (version 0.9.1), I open another tab in my terminal and I use that command:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>$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
  </code></pre>
  
  <p>Ask me if you want some more specific details. Thanks for your attention :)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>After those 2 modifications, I tested again, running docker daemon with -D option this time. Here is the output (split into 3 parts):</p>
  
  <p><a href="https://gist.github.com/ekeryelleven/9714312c45b7ff21ce2a" rel="nofollow">https://gist.github.com/ekeryelleven/9714312c45b7ff21ce2a</a></p>
  
  <p>I launched the registry container (from another terminal tab): <a href="https://gist.github.com/ekeryelleven/b9bfa50bfe3221798659" rel="nofollow">https://gist.github.com/ekeryelleven/b9bfa50bfe3221798659</a></p>
  
  <p>Then, I pushed: <a href="https://gist.github.com/ekeryelleven/80f8f1d1dad00b0fbea9" rel="nofollow">https://gist.github.com/ekeryelleven/80f8f1d1dad00b0fbea9</a></p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Somebody told me it was possibly linked to <a href="https://github.com/docker/docker/issues/9315" rel="nofollow">https://github.com/docker/docker/issues/9315</a></p>
  
  <p>I tried to reproduce:</p>
  
  <pre><code>$ 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 &lt;proxy&gt;... &lt;ip&gt;
  Connecting to &lt;proxy&gt;|&lt;ip&gt;|:&lt;port&gt;... connected.
  Proxy request sent, awaiting response... 504 Gateway Timeout
  2015-04-16 11:01:42 ERROR 504: Gateway Timeout.
  </code></pre>
  
  <p>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):</p>
  
  <p><a href="http://pastebin.com/raw.php?i=XaJaSsWk" rel="nofollow">http://pastebin.com/raw.php?i=XaJaSsWk</a></p>
  
  <p>Launching the registry container: <a href="http://pastebin.com/raw.php?i=1tux468H" rel="nofollow">http://pastebin.com/raw.php?i=1tux468H</a></p>
  
  <p>Pushing: <a href="http://pastebin.com/raw.php?i=LsvNfdQf" rel="nofollow">http://pastebin.com/raw.php?i=LsvNfdQf</a></p>