1

假设“foo”是存储库名称,我想调用具有两个标签“boo,boo-0011”的图像

此命令显示存储库中的所有图像:

aws ecr describe-images --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]"

从这里我如何只grep带有标签“boo”的那个

4

2 回答 2

2

您可以使用--filter tagStatus=xxx,但这只允许您过滤已标记或未标记的图像,而不是具有特定标签的图像。

要查找带有特定标签的图像,例如boo,您应该能够使用有点难以理解但非常有用的jq实用程序。例如:

aws ecr describe-images \
    --region us-east-1 \
    --repository-name foo \
    --filter tagStatus=TAGGED \
    | jq -c '.imageDetails[] | select([.imageTags[] == "boo"] | any)'
于 2019-01-25T21:52:26.053 回答
1

我个人为此使用 grep

aws ecr describe-images --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]" | grep -w 'boo'

-w 是整个单词匹配的 grep 命令。

于 2020-05-21T09:38:15.987 回答