0

Is there a way to find the age of a Docker image pushed to AWS ECR?

When I ask for the image manifest with aws ecr batch-get-image --repository some/repo --image-ids "imageDigest=sha256:abcdef..." then it returns the AWS reply with the embedded manifest. Sample output

{
  "images": [
     {
        "registryId": "1234",
        "imageId": {
          "imageDigest": "sha256:abcdef...",
          "imageTag": "latest"
         }
      },
      "imageManifest": "<serialised JSON I'll paste below>"
      "repositoryName": "some/repo"
     }
    ],
   "failures": []
}

and the serialised JSON embedded in the AWS response looks along these lines:

{
  "schemaVersion": 2,
  "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
  "config": {
    "mediaType": "application/vnd.docker.container.image.v1+json",
    "size": 123456,
    "digest": "sha256:38f08cc551925935e235c5c94ab3fb89568bd286e3335aa2e05d7bd3ceee4574"
  },
  "layers": [
    {
      "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
      "size": 573764,
      "digest": "sha256:06dde66f337b57adcfca48b87d126b99a249765ccf2e09964584befc2890ae79"
    }
  ]
}

there is no metadata that I can see indicating when this image was pushed to ECR.

1

It turns out I did not have enough permissions (lacked ecr:ListImages) to use aws ecr describe-images. With appropriate permissions I can run that sub-command and see the imagePushedAt. E.g.

{
    "imageDetails": [
        {
            "imageDigest": "sha256:309b3ae71cf0780232cb013fb77507977625f8fe8cee868feca2649890ae073b",
            "repositoryName": "somerepo/someimage",
            "registryId": "12345",
            "imagePushedAt": 1485358557.0,
            "imageSizeInBytes": 8986900
        },
        {
            "imageDigest": "sha256:036a5da0dd8ef4a949293818cb05d15aaa31f2e8d9f464f9376667be9919e646",
            "repositoryName": "somerepo/someimage",
            "registryId": "12345",
            "imagePushedAt": 1485362799.0,
            "imageSizeInBytes": 8986643
        },
  ... and so on ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.