假设“foo”是存储库名称,我想调用具有两个标签“boo,boo-0011”的图像
此命令显示存储库中的所有图像:
aws ecr 描述图像 --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]"
从此我如何只 grep 带有标签“boo”的那个
您可以使用
--filter tagStatus=xxx
,但这仅允许您过滤已标记或未标记的图像,而不是具有特定标记的图像。
要查找带有特定标签的图像,例如
boo
,您应该能够使用有点难以理解但非常有用的 jq 实用程序。例如:
aws ecr describe-images \
--region us-east-1 \
--repository-name foo \
--filter tagStatus=TAGGED \
| jq -c '.imageDetails[] | select( .imageTags[] | contains("boo") )'
我个人使用 grep 来实现此目的
aws ecr describe-images --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]" | grep -w 'boo'
-w 是全词匹配的 grep 命令。