title: Docker remote api pull from Docker hub private registry
body: <p>I'm trying to pull docker images from a private repository hosted in Docker hub <a href="https://registry.hub.docker.com/u/myname/myapp" rel="noreferrer">https://registry.hub.docker.com/u/myname/myapp</a> like this using the docker remote API. The <a href="https://docs.docker.com/reference/api/hub_registry_spec/#the-api" rel="noreferrer">doc</a> is not clear as to how to specify the authentication credentials in a POST request like this</p>
  
  <pre><code>curl -XPOST -H "X-Registy-Auth: base64_encoded_authconfig_object" "http://localhost:4243/images/create?fromImage=myname/myapp"
  </code></pre>
  
  <p><a href="https://docs.docker.com/reference/api/docker_remote_api_v1.11/" rel="noreferrer">This</a> also does not elaborate on how exactly the authconfig is generated.</p>
  
  <p><a href="http://permalink.gmane.org/gmane.comp.sysutils.docker.user/3568" rel="noreferrer">This</a> talks about sending in a base 64 encoded json with a structure like this:</p>
  
  <pre><code>{
    "index_url": {
      "username": "string",
      "password": "string",
      "email": "string",
      "serveraddress": "string"
    }
  }
  </code></pre>
  
  <p>But doesnt explain what is index_url and serveraddress. Are they </p>
  
  <pre><code>index_url = https://registry.hub.docker.com/u/myname/myapp
  serveraddress = https://registry.hub.docker.com
  </code></pre>
  
  <p>The above configurations give me 404, probably the registry hub private repo is not being recognized.</p>
  
  <p>I also tried base 64 encoding the contents of my ~/.dockercfg</p>
  
  <pre><code>{
    "https://index.docker.io/v1/": {
      "auth":"xxxxxxxxxxxxxxxxxxx==",
      "email":"myname@myemail.com"
    }
  }
  </code></pre>
  
  <p>Could you tell me how to generate the base64 encoded authconfig object and get the above curl command working. </p>
  
  <p>Thanks in advance</p>
  
  <p><strong>Docker version</strong> </p>
  
  <pre><code>Client version: 0.11.1
  Client API version: 1.11
  Go version (client): go1.2.1
  Git commit (client): fb99f99
  Server version: 0.11.1
  Server API version: 1.11
  Git commit (server): fb99f99
  Go version (server): go1.2.1
  </code></pre>