title: Using private registry hosted on docker
body: <p>I'm hosting my own docker-registry in a docker container. It's fronted by nginx running in a separate container to add basic auth. Checking the _ping routes I can see that nginx is routing appropriately. When calling <code>docker login</code> from boot2docker (on Mac OSX) I get this error:</p>
  
  <blockquote>
    <p>FATA[0003] Error response from daemon: Invalid registry endpoint <a href="https://www.example.com:8080/v1/" rel="nofollow noreferrer">https://www.example.com:8080/v1/</a>: Get <a href="https://www.example.com:8080/v1/_ping" rel="nofollow noreferrer">https://www.example.com:8080/v1/_ping</a>: x509: certificate signed by unknown authority. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add <code>--insecure-registry www.example.com:8080</code> to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/www.example.com:8080/ca.crt </p>
  </blockquote>
  
  <p>Which is odd - because it's a valid CA SSL cert. I've tried adding <code>--insecure-registry</code> in EXTRA-ARGS as per these instructions: <a href="https://github.com/boot2docker/boot2docker#insecure-registry" rel="nofollow noreferrer">https://github.com/boot2docker/boot2docker#insecure-registry</a> but initially the 'profile' file doesn't exist it. If I create it, and add </p>
  
  <pre><code>EXTRA_ARGS="--insecure-registry www.example.com:8080"
  </code></pre>
  
  <p>I see no improvement. I wanted to isolate the example and so tried <code>docker login</code> from an ubuntu VM (not boot2docker). Now I get a different error:</p>
  
  <pre><code>Error response from daemon: 
  </code></pre>
  
  <p>The docker registry is run directly from the public hub, e.g.</p>
  
  <pre><code>docker run -d -p 5000:5000 registry
  </code></pre>
  
  <p>(Note that nginx routes from 8080 to 5000). Any help and/or resources to help debug this would be much appreciated. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I was looking to a guide to help comprehensively solve this problem. Specifically:</p>
  
  <ul>
  <li>Create a private registry</li>
  <li>Secure the registry with basic Auth</li>
  <li>Use the registry from boot2docker</li>
  </ul>
  
  <p>I have created the registry and tested locally, it works. I have secured the registry with nginx adding basic auth. </p>
  
  <p>The trouble is now actually using the registry from two types of client:</p>
  
  <p>1) Non boot2docker client. 
  One of the answers below helped with this. I added --insecure-registry flag to options in  /etc/default/docker and now I can talk to my remote docker registry.
  However, this isn't compatible with auth as docker login gets an error: </p>
  
  <pre><code>2015/01/15 21:33:57 HTTP code 401, Docker will not send auth headers over HTTP.
  </code></pre>
  
  <p>So, if I want to use auth I'll need to use HTTPS. I already have this server serving over HTTPS but that doesn't work if I set --insecure-registry. There appears to be a certificate trust issue, which I'm confident I can solve on non-boot2docker but.. </p>
  
  <p>2) For a boot2docker client, I can't get --insecure-registry to work or certificates to be trusted? </p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Following <a href="https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate/94861#94861?newreg=0bfdb6d5725f4e2fa6a7d72e18685d49">this stack exchange</a> question I managed to add the ca to my ubuntu VM and I can now use from non boot2docker client. However, there is still a lot of odd behavior.</p>
  
  <p>Even though my current user is a member of the docker group (so I don't have to use sudo) I now have to use sudo or I get the following error when trying to login or pull <em>from my private registry</em></p>
  
  <pre><code>user@ubuntu:~$ docker login example.com:8080
  WARNING: open /home/parallels/.dockercfg: permission denied
  
  parallels@ubuntu:~$ docker pull example.com:8080/hw:1
  WARNING: open /home/parallels/.dockercfg: permission denied
  </code></pre>
  
  <p>And when running containers pulled from my private registry for the first time, I have to specify them by image ID - not their name.</p>