title: How can I use Docker Registry HTTP API V2 to obtain a list of all repositories in a docker registry?
body: <p>An external organization that I work with has given me access to a private (auth token protected) docker registry, and eventually I would like to be able to query this registry, using docker's HTTP API V2, in order to obtain a list of all the repositories and/or images available in the registry.</p>
  
  <p>But before I do that, I'd first like to get some basic practice with constructing these types of API queries on a public registry such as <a href="https://hub.docker.com" rel="noreferrer">Docker Hub</a>.  So I've gone ahead and <a href="https://hub.docker.com/u/stachyra" rel="noreferrer">registered myself</a> with a username and password on Docker Hub, and also consulted the API V2 documentation, which states that one may request an <a href="https://docs.docker.com/registry/spec/api/#api-version-check" rel="noreferrer">API version check</a> as:</p>
  
  <pre><code>GET /v2/
  </code></pre>
  
  <p>or request a <a href="https://docs.docker.com/registry/spec/api/#listing-repositories" rel="noreferrer">list of repositories</a> as:</p>
  
  <pre><code>GET /v2/_catalog
  </code></pre>
  
  <p>Using curl, together with the username and password that I used in order to register my Docker Hub account, I attempt to construct a GET request at the command line:</p>
  
  <pre><code>stachyra&gt; curl -u stachyra:&lt;my_password&gt; -X GET https://index.docker.io/v2/
  {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
  stachyra&gt; curl -u stachyra:&lt;my_password&gt; -X GET https://index.docker.io/v2/_catalog
  {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"registry","Class":"","Name":"catalog","Action":"*"}]}]}
  </code></pre>
  
  <p>where of course, in place of <code>&lt;my_password&gt;</code>, I substituted my actual account password.</p>
  
  <p>The response that I had been expecting from this query was a giant json message, listing thousands of repository names, but instead it appears that the API is rejecting my Docker Hub credentials.</p>
  
  <p><strong>Question 1:</strong> Do I even have the correct URL (<code>index.docker.io</code>) for the docker hub registry?  (I made this assumption in the first place based upon the status information returned by the command line tool <code>docker info</code>, so I have good reason to think it's correct.)</p>
  
  <p><strong>Question 2:</strong> Assuming I have the correct URL for the registry service itself, why does my query return an "UNAUTHORIZED" error code?  My account credentials work just fine when I attempt to login via the web at hub.docker.com, so what's the difference between the two cases?</p>