AWS CLI: ECR list-images, get newest

前端 未结 5 1008
不思量自难忘°
不思量自难忘° 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:41

    To add to Frederic's answer, if you want the latest, you can use [-1]:

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

    Assuming you are using a singular tag on your images... otherwise you might need to use imageTags[*] and do a little more work to grab the tag you want.

提交回复
热议问题