title: How to determine the Docker image ID for a tag via Docker Hub API?
body: <p>Given a tag `latest`, we want to find out another tag with the same image ID on Docker Hub.</p>
  
  <p>Here is how to find out all tags for a repo with the Docker Hub API v2:</p>
  
  <pre><code>TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
  curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/fluent/fluentd/tags/?page_size=100 | jq
  </code></pre>
  
  <p>(See <a href="https://gist.github.com/kizbitz/175be06d0fbbb39bc9bfa6c0cb0d4721" rel="noreferrer">gist.github.com/kizbitz</a>)</p>
  
  <p>Unfortunately, it doesn't contain the image ID but always a `null` value for this key:</p>
  
  <pre><code>$ curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/fluent/fluentd/tags/?page_size=100 | jq
  {
    "count": 36,
    "next": null,
    "previous": null,
    "results": [
  ...
      {
        "name": "v0.14.11",
        "full_size": 11964464,
        "id": 7084687,
        "repository": 219785,
        "creator": 2923,
        "last_updater": 2923,
        "last_updated": "2016-12-27T07:16:41.294807Z",
        "image_id": null,
        "v2": true,
        "platforms": [
          5
        ]
      },
  ...
  </code></pre>
  
  <p>Unfortunately, the image ID is something different than the `id` in the JSON above.</p>
  
  <pre><code>$ docker images | grep fluent
  docker.io/fluent/fluentd                  v0.14.11            1441d57beff9        3 weeks ago         38.25 MB
  </code></pre>
  
  <p>Theoretically, it should be possible to access the Docker Manifests and along with the the image ID with this Docker Registry call but it doesn't help either:</p>
  
  <pre><code>$ curl -s -H "Authorization: JWT ${TOKEN}" "https://registry.hub.docker.com/v2/fluent/fluentd/manifests/latest"
  {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Name":"fluent/fluentd","Action":"pull"}]}]}
  </code></pre>
  
  <p>(See <a href="https://stackoverflow.com/questions/37758258/is-that-possible-to-get-image-id-from-docker-registry-v2">stackoverflow.com</a>)</p>
  
  <p>Here is a similar issue in the Docker GitHub repo but I still cannot figure out the solution: <a href="https://github.com/docker/distribution/issues/1490" rel="noreferrer">https://github.com/docker/distribution/issues/1490</a> .</p>
  
  <p>P.S.: Here is my Docker version with which I tried to push a test image:</p>
  
  <pre><code>$ docker version
  Client:
   Version:         1.12.6
   API version:     1.24
   Package version: docker-common-1.12.6-5.git037a2f5.fc25.x86_64
   Go version:      go1.7.4
   Git commit:      037a2f5/1.12.6
   Built:           Wed Jan 18 12:11:29 2017
   OS/Arch:         linux/amd64
  </code></pre>