Docker Community Forums

Share and learn in the Docker community.

Retrieving pre 1.10 layer hashes

I’ve been struggling a lot with this recently. I recently found this post - Understand images, containers, and storage drivers which details the change to content-addressable storage. The article notes that post 1.10 when you pull an image the layer directories stored on your computer do not match up with the layer IDs pulled when executing docker pull.

I have been trying to retrieve the layer IDs that are stored locally (pre 1.10) with the currently existing APIs. I have not been able to find a correlation between the two anywhere. If anyone knows how to accomplish this I would greatly appreciate the help.

Here’s a more concrete example of what I’m talking about:

$ docker pull ubuntu:15.04
15.04: Pulling from library/ubuntu
1ba8ac955b97: Pull complete
f157c4e5ede7: Pull complete
0b7e98f84c4c: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:5e279a9df07990286cce22e1b0f5b0490629ca6d187698746ae5e28e604a640e
Status: Downloaded newer image for ubuntu:15.04

$ ls /var/lib/docker/aufs/layers/
1d6674ff835b10f76e354806e16b950f91a191d3b471236609ab13a930275e24
5dbb0cbe0148cf447b9464a358c1587be586058d9a4c9ce079320265e2bb94e7
bef7199f2ed8e86fa4ada1309cfad3089e0542fec8894690529e4c04a7ca2d73
ebf814eccfe98f2704660ca1d844e4348db3b5ccc637eb905d4818fbfb00a06a

Notice how the layer IDs do not match. I’m trying to retrieve the latter IDs but the API only returns the new layer IDs in the fsLayers array.

GET /v2/library/ubuntu/manifests/15.04

{    
  "schemaVersion": 1,
  "name": "library/ubuntu",
  "tag": "15.04",
  "architecture": "amd64",
  "fsLayers": [
    {
      "blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
    },
    {
      "blobSum": "sha256:2f937cc07b5fa0c9dc466c1421227981c80e48fdd944f8e9c215544bbd34bbc0"
    },
    {
      "blobSum": "sha256:4332ffb06e4b2a63e6feb5db60fd03c073624e1df32a5dc128bede49f71b3a5e"
    },
    {
      "blobSum": "sha256:9502adfba7f1250b1d7fc248ff95dc34e90cad1b554a3151819f8a33ada37dfb"
    }
  ],
  "history": [
    {
      "v1Compatibility": "{\"id\":\"314a1f0785309b773392e11208cb29ec370cf416eb3c828c7e45ff66b0fb0e20\",\"parent\":\"4913eece27c087d06635d32b98c50464b2f1d17bba86be7d4616738f1cfef0af\",\"created\":\"2016-01-26T17:48:34.465253028Z\",\"container\":\"cc20825e9e02f79fe62f1b08bc30aea4299dbcd77ad0da58b00dec38aba7334a\",\"container_config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":[\"/bin/sh\",\"-c\",\"#(nop) CMD [\"/bin/bash\"]\"],\"Image\":\"4913eece27c087d06635d32b98c50464b2f1d17bba86be7d4616738f1cfef0af\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"docker_version\":\"1.8.3\",\"config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":[\"/bin/bash\"],\"Image\":\"4913eece27c087d06635d32b98c50464b2f1d17bba86be7d4616738f1cfef0af\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"architecture\":\"amd64\",\"os\":\"linux\"}"
    },
    {
      "v1Compatibility": "{\"id\":\"4913eece27c087d06635d32b98c50464b2f1d17bba86be7d4616738f1cfef0af\",\"parent\":\"d09407f461e5b05264de993af2d9d1d1cdfc9376906375df71f94b07d91fef2d\",\"created\":\"2016-01-26T17:48:33.59869621Z\",\"container\":\"042f4830ebb6dd5658bd90ddb97b62eb8f1d9ebab9845826d746af97e4956ad0\",\"container_config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":[\"/bin/sh\",\"-c\",\"sed -i 's/^#\\\\s*\\\\(deb.*universe\\\\)$/\\\\1/g' /etc/apt/sources.list\"],\"Image\":\"d09407f461e5b05264de993af2d9d1d1cdfc9376906375df71f94b07d91fef2d\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"docker_version\":\"1.8.3\",\"config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":null,\"Image\":\"d09407f461e5b05264de993af2d9d1d1cdfc9376906375df71f94b07d91fef2d\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"architecture\":\"amd64\",\"os\":\"linux\",\"Size\":1879}"
    },
    {
      "v1Compatibility": "{\"id\":\"d09407f461e5b05264de993af2d9d1d1cdfc9376906375df71f94b07d91fef2d\",\"parent\":\"c9a73777916c475bed83fce9821c785e14c7178008d28d54e7af65377bcfaad0\",\"created\":\"2016-01-26T17:48:31.377192721Z\",\"container\":\"343ad116b8666783097ba66ce2880749260a65ad63361c473b9ed82b35229f6b\",\"container_config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":[\"/bin/sh\",\"-c\",\"echo '#!/bin/sh' \\u003e /usr/sbin/policy-rc.d \\t\\u0026\\u0026 echo 'exit 101' \\u003e\\u003e /usr/sbin/policy-rc.d \\t\\u0026\\u0026 chmod +x /usr/sbin/policy-rc.d \\t\\t\\u0026\\u0026 dpkg-divert --local --rename --add /sbin/initctl \\t\\u0026\\u0026 cp -a /usr/sbin/policy-rc.d /sbin/initctl \\t\\u0026\\u0026 sed -i 's/^exit.*/exit 0/' /sbin/initctl \\t\\t\\u0026\\u0026 echo 'force-unsafe-io' \\u003e /etc/dpkg/dpkg.cfg.d/docker-apt-speedup \\t\\t\\u0026\\u0026 echo 'DPkg::Post-Invoke { \"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true\"; };' \\u003e /etc/apt/apt.conf.d/docker-clean \\t\\u0026\\u0026 echo 'APT::Update::Post-Invoke { \"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true\"; };' \\u003e\\u003e /etc/apt/apt.conf.d/docker-clean \\t\\u0026\\u0026 echo 'Dir::Cache::pkgcache \"\"; Dir::Cache::srcpkgcache \"\";' \\u003e\\u003e /etc/apt/apt.conf.d/docker-clean \\t\\t\\u0026\\u0026 echo 'Acquire::Languages \"none\";' \\u003e /etc/apt/apt.conf.d/docker-no-languages \\t\\t\\u0026\\u0026 echo 'Acquire::GzipIndexes \"true\"; Acquire::CompressionTypes::Order:: \"gz\";' \\u003e /etc/apt/apt.conf.d/docker-gzip-indexes\"],\"Image\":\"c9a73777916c475bed83fce9821c785e14c7178008d28d54e7af65377bcfaad0\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"docker_version\":\"1.8.3\",\"config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":null,\"Image\":\"c9a73777916c475bed83fce9821c785e14c7178008d28d54e7af65377bcfaad0\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"architecture\":\"amd64\",\"os\":\"linux\",\"Size\":701}"
    },
    {
      "v1Compatibility": "{\"id\":\"c9a73777916c475bed83fce9821c785e14c7178008d28d54e7af65377bcfaad0\",\"created\":\"2016-01-26T17:48:17.324409116Z\",\"container\":\"d2d404286fc43394650685c2b205651f02dd5c0c859fe190bdee1a7c0db9b2eb\",\"container_config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":[\"/bin/sh\",\"-c\",\"#(nop) ADD file:3f4708cf445dc1b537b8e9f400cb02bef84660811ecdb7c98930f68fee876ec4 in /\"],\"Image\":\"\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"docker_version\":\"1.8.3\",\"config\":{\"Hostname\":\"d2d404286fc4\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":null,\"Cmd\":null,\"Image\":\"\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"architecture\":\"amd64\",\"os\":\"linux\",\"Size\":131296918}"
    }
  ],
  "signatures": [
    {
      "header": {
        "jwk": {
          "crv": "P-256",
          "kid": "SS4J:74QQ:YPH4:PONS:J4AA:V4NF:HPY6:MQY5:5BSD:VCPW:BLEO:VDO3",
          "kty": "EC",
          "x": "Zrqb46cPdQAWEfmjdxBD1BoUZJKeoyQwUzyzelrzH94",
          "y": "UZeytrw5_Qv4C8FC1OPgKYZUMNLUE6W0h7yPZK00rFE"
        },
        "alg": "ES256"
      },
      "signature": "i2Befl1zE7gzpM_EQ4LpbdKeB30XC0cpYSGcnTVTQj93bpCD7O_eSAy5F9KyYw-G3czA2BfgFiqLJDyKls7sFQ",
      "protected": "eyJmb3JtYXRMZW5ndGgiOjY4MDEsImZvcm1hdFRhaWwiOiJDbjAiLCJ0aW1lIjoiMjAxNy0wMS0zMVQxNjoxMToyNVoifQ"
    }
  ]
}