Service Fabric 容器部署期间的激活路径处理将容器映像下载到运行容器的 VM。 从群集中移除容器并取消其应用程序类型的注册后,将会经过清理周期来删除容器映像。 仅当容器映像在服务清单中硬编码时,此容器映像清理才会正常运行。 对于现有的 Service Fabric 运行时版本,支持清理容器映像的配置如下所示:
"fabricSettings": [
{
"name": "Hosting",
"parameters": [
{
"name": "PruneContainerImages",
"value": "true"
},
{
"name": "CacheCleanupScanInterval",
"value": "3600"
}
]
}
]
设置 | 说明 |
---|---|
PruneContainerImage | 设置为在注销应用程序类型时启用或禁用容器映像删除。 |
CacheCleanupScanInterval | 设置(以秒为单位)确定清理周期的运行频率。 |
从 Service Fabric 版本 10.0 开始,有较新版本的容器映像删除流。 此流会清理容器映像,而不考虑容器映像的定义方式,即它在应用程序部署期间是硬编码还是参数化的。 PruneContainerImages 和 ContainerImageDeletionEnabled 配置互斥,并且存在群集升级验证,以确保打开其中一个或另一个,但不能同时打开两者。 支持此功能的配置如下所示:
"fabricSettings": [
{
"name": "Hosting",
"parameters": [
{
"name": "ContainerImageDeletionEnabled",
"value": "true"
},
{
"name": "ContainerImageCleanupInterval",
"value": "3600"
},
{
"name": "ContainerImageTTL",
"value": "3600"
},
{
"name": "ContainerImageDeletionOnAppInstanceDeletionEnabled",
"value": "true"
},
{
"name": "ContainerImagesToSkip",
"value": "microsoft/windowsservercore|microsoft/nanoserver"
}
]
}
]
设置 | 说明 |
---|---|
ContainerImageDeletionEnabled | 设置为启用或禁用容器映像删除。 |
ContainerImageCleanupInterval | 清理未使用的容器映像的时间间隔。 |
ContainerImageTTL | 容器映像符合删除条件后的生存时间(VM 上的容器未引用,并且应用程序已删除(如果启用 ContainerImageDeletionOnAppInstanceDeletionEnabled))。 |
ContainerImageDeletionOnAppInstanceDeletionEnabled | 仅在应用程序也被删除后,才能设置启用或禁用过期 ttl 容器映像删除。 |
ContainerImagesToSkip | 设置后,容器运行时可以跳过删除与任何正则表达式集匹配的映像。 | 字符分隔每个表达式。 示例:“mcr.microsoft.com/.+|docker.io/library/alpine:latest”- 此示例匹配前缀为“mcr.microsoft.com/”的所有内容,并完全匹配“docker.io/library/alpine:latest”。 默认情况下,我们不会删除已知的 Windows 基础映像 microsoft/windowsservercore 或 microsoft/nanoserver。 |