AWS CLI: ECR list-images, get newest

前端 未结 5 996
不思量自难忘°
不思量自难忘° 2020-12-31 04:48

Using AWS CLI, and jq if needed, I\'m trying to get the tag of the newest image in a particular repo.

Let\'s call the repo foo, and sa

5条回答
  •  轮回少年
    2020-12-31 05:46

    You can use describe-images instead.

    aws ecr describe-images --repository-name foo 
    

    returns imagePushedAt which is a timestamp property which you can use to filter.

    I dont have examples in my account to test with but something like following should work

    aws ecr describe-images --repository-name foo \
    --query 'sort_by(imageDetails,& imagePushedAt)[*]'
    

    If you want another flavor of using sort method, you can review this post

提交回复
热议问题