amazon-web-servicesdockeraws-ecs

How to run Docker inspect to obtain image meta-data of an image in the ECR registry


I have the relevant access to the ECR registry however i am not able to get image meta data by running the Docker inspect command. I am trying with

docker inspect ecrregistryurl/dockerimage:imageversion

Solution

  • update

    If you are using recent version as mentioned by @muya_, you can use

    aws ecr get-login-password | docker login -u AWS --password-stdin https://account-id.dkr.ecr.eu-west-1.amazonaws.com
    

    As mentioned by @Tarun I tried it but it's not giving me the same output as docker inspect. Here is the link from the documentation. https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html#registry_auth_http

    #!/bin/bash
    TOKEN=$(aws ecr get-authorization-token --output text --query authorizationData[].authorizationToken)
    curl -i -H "Authorization: Basic $TOKEN" https://account_id.dkr.ecr.us-west-2.amazonaws.com/v2/redis/manifests/latest 
    

    But check the output it's different from docker inspect.

    Docker inspect image_name
    

    This command will only inspect your local images instead of your Registry.

    What you can do to get only relevant metadata that provides ECR.

    aws ecr list-images --repository-name redis
    

    It will give you an image tag and image id.

    aws ecr describe-images --repository-name redis
    

    This will give all the image and some more detail in this repo named redis.

    Now, For docker inspect first pull that images.

    aws ecr get-login --no-include-email
    

    run the output of this command. You will get a login using the token.

    docker pull account_id.dkr.ecr.us-west-2.amazonaws.com/redis:latest

    then run

    docker pull account_id.dkr.ecr.us-west-2.amazonaws.com/redis:latest
    

    You will get what you are looking for.

    Or if you already running this image at some ec2 instance then run on that ec2 instance you will get the desired result.

    docker inspect account_id.dkr.ecr.us-west-2.amazonaws.com/redis:latest
    

    https://docs.aws.amazon.com/cli/latest/reference/ecr/index.html