如果您只有一个规则,它确实会删除您的稳定图像。
但是,您可以通过策略中的 2 条规则来完成此操作。优先级为 10 的规则将确保您的稳定镜像 (16.XXXX) 安全,优先级为 20 的规则将“查看”您的不稳定版本 (16_XXXX) 的标签数量,但永远无法删除稳定镜像,因为它处于更高的优先级。这是一个例子:
{
"rules": [
{
"rulePriority": 10,
"description": "Keep Stable Images",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["16."],
"countType": "imageCountMoreThan",
"countNumber": 9999
},
"action": {
"type": "expire"
}
},
{
"rulePriority": 20,
"description": "Delete Old Unstable Images",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["16_"],
"countType": "imageCountMoreThan",
"countNumber": 500
},
"action": {
"type": "expire"
}
}
]
}
资料来源:我为 Lifecycle Policies 编写了规则评估逻辑 :) 您还可以查看文档,在此页面底部描述了用户可以利用的系统的一些事实:https ://docs.aws.amazon.com /AmazonECR/latest/userguide/LifecyclePolicies.html
An image that matches the tagging requirements of a rule cannot be expired by a rule with a lower priority.