假设“foo”是存储库名称,我想调用具有两个标签“boo,boo-0011”的图像
此命令显示存储库中的所有图像:
aws ecr describe-images --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]"
从这里我如何只grep带有标签“boo”的那个
假设“foo”是存储库名称,我想调用具有两个标签“boo,boo-0011”的图像
此命令显示存储库中的所有图像:
aws ecr describe-images --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[] == "boo"] | any)'
我个人为此使用 grep
aws ecr describe-images --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]" | grep -w 'boo'
-w 是整个单词匹配的 grep 命令。