AWS CLI:ECR 列表图像,获取最新信息 [英] AWS CLI: ECR list-images, get newest

查看:25
本文介绍了AWS CLI:ECR 列表图像,获取最新信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 AWS CLI 和 jq(如果需要),我正在尝试获取特定存储库中最新图像的标签.

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

让我们调用 repo foo,并说最新的图像被标记为 bar.我使用什么查询来返回 bar?

Let's call the repo foo, and say the latest image is tagged bar. What query do I use to return bar?

我已经到了

aws ecr list-images --repository-name foo

然后意识到list-images 文档 没有将日期作为可查询字段进行引用.将上面的内容粘贴到终端中,我得到的密钥对只有标签和摘要,没有日期.

and then realized that the list-images documentation gives no reference to the date as a queryable field. Sticking the above in a terminal gives me keypairs with just the tag and digest, no date.

还有什么方法可以获得最新"的图像吗?我可以假设它始终是返回的输出中的第一个或最后一个吗?

Is there still some way to get the "latest" image? Can I assume it'll always be the first, or the last in the returned output?

推荐答案

您可以使用 describe-images 代替.

You can use describe-images instead.

aws ecr describe-images --repository-name foo 

返回 imagePushedAt 这是一个时间戳属性,您可以使用它来过滤.

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

这篇关于AWS CLI:ECR 列表图像,获取最新信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆