title: What is the canonical way to see if an image exists in the docker public registry?
body: <p>We want to check if an image exists in the public registry (Docker Hub) automatically before we start a deployment. With the v1 API, we would just query <code>https://index.docker.io/v1/repositories/gliderlabs/alpine/tags/3.2</code> for example.</p>
  
  <p>But now the official API for the registry is v2, what is the official way of checking the existence of an image in the <strong>public</strong> registry?</p>
  
  <p><strong>v1</strong></p>
  
  <pre><code>$ curl -i https://index.docker.io/v1/repositories/gliderlabs/alpine/tags/latest
  HTTP/1.1 200 OK
  Server: nginx/1.6.2
  Date: Tue, 11 Aug 2015 10:02:09 GMT
  Content-Type: application/json
  Transfer-Encoding: chunked
  Vary: Cookie
  X-Frame-Options: SAMEORIGIN
  Strict-Transport-Security: max-age=31536000
  
  [{"pk": 20307475, "id": "5bd56d81"}, {"pk": 20355979, "id": "511136ea"}]
  </code></pre>
  
  <p><strong>v2</strong>:</p>
  
  <pre><code>$ curl -i https://index.docker.io/v2/repositories/gliderlabs/alpine/tags/latest
  HTTP/1.1 301 MOVED PERMANENTLY
  Server: nginx/1.6.2
  Date: Tue, 11 Aug 2015 10:04:20 GMT
  Content-Type: text/html; charset=utf-8
  Transfer-Encoding: chunked
  X-Frame-Options: SAMEORIGIN
  Location: https://index.docker.io/v2/repositories/gliderlabs/alpine/tags/latest/
  Strict-Transport-Security: max-age=31536000
  
  $ curl -i https://index.docker.io/v2/repositories/gliderlabs/alpine/tags/latest/
  HTTP/1.1 301 MOVED PERMANENTLY
  Server: nginx/1.6.2
  Date: Tue, 11 Aug 2015 10:04:26 GMT
  Content-Type: text/html; charset=utf-8
  Transfer-Encoding: chunked
  X-Frame-Options: SAMEORIGIN
  Location: https://registry.hub.docker.com/v2/repositories/gliderlabs/alpine/tags/latest/
  Strict-Transport-Security: max-age=31536000
  
  $ curl -i https://registry.hub.docker.com/v2/repositories/gliderlabs/alpine/tags/latest/
  HTTP/1.1 200 OK
  Server: nginx/1.6.2
  Date: Tue, 11 Aug 2015 10:04:34 GMT
  Content-Type: application/json
  Transfer-Encoding: chunked
  Vary: Cookie
  X-Frame-Options: SAMEORIGIN
  Allow: GET, DELETE, HEAD, OPTIONS
  Strict-Transport-Security: max-age=31536000
  
  {"name": "latest", "full_size": 5250074, "id": 130839, "repository": 127805, "creator": 152141, "last_updater": 152141, "image_id": null, "v2": false}
  </code></pre>
  
  <p>Am I supposed to stick to the <code>v1</code> url even though it is now kind of deprecated or use <code>v2</code> URLs but there is no documentation about it? If I use <code>v2</code>, shall I use directly <code>https://registry.hub.docker.com/v2/</code> or still use <code>https://index.docker.io/v1/</code> and follow the redirects?</p>