清理映像资源 - Amazon SageMaker AI

清理映像资源

本指南介绍如何清理您在前面部分中创建的 RStudio 映像资源。要删除映像,请使用 SageMaker AI 控制台或 AWS CLI 按照本指南中所示完成以下步骤。

  • 从您的 Amazon SageMaker AI 域中分离映像和映像版本。

  • 删除映像、映像版本和应用程序映像配置。

完成这些步骤后,您可以从 Amazon ECR 中删除容器映像和存储库。有关如何删除容器映像和存储库的更多信息,请参阅删除存储库

从 SageMaker AI 控制台清理资源

从域中分离映像时,将分离该映像的所有版本。分离映像后,域的所有用户都将失去对映像版本的访问权限。

分离映像
  1. 通过 https://console.aws.amazon.com/sagemaker/ 打开 Amazon SageMaker AI 控制台。

  2. 在左侧导航窗格中,选择管理员配置

  3. 管理员配置下,选择

  4. 选择所需的域。

  5. 选择环境

  6. 附加到域的自定义映像下,选择映像,然后选择分离

  7. (可选)要从 SageMaker AI 中删除映像和所有版本,请选择同时删除选定的映像...。这不会从 Amazon ECR 中删除关联的映像。

  8. 选择分离

通过 AWS CLI 清理资源

清理资源
  1. 通过向域传递一个空的自定义映像列表,将映像和映像版本从域中分离。打开在 将 SageMaker 映像附加到当前域 中创建的 update-domain-input.json 文件。

  2. 删除 RSessionAppSettings 自定义映像,然后保存文件。请勿修改 KernelGatewayAppSettings 自定义映像。

    { "DomainId": "d-xxxxxxxxxxxx", "DefaultUserSettings": { "KernelGatewayAppSettings": { "CustomImages": [ ], ... }, "RSessionAppSettings": { "CustomImages": [ ], "DefaultResourceSpec": { } ... } } }
  3. 使用域 ID 和默认用户设置文件更新域。

    aws sagemaker update-domain \ --domain-id <d-xxxxxxxxxxxx> \ --cli-input-json file://update-domain-input.json

    响应:

    { "DomainArn": "arn:aws:sagemaker:us-east-2:acct-id:domain/d-xxxxxxxxxxxx" }
  4. 删除应用程序映像配置。

    aws sagemaker delete-app-image-config \ --app-image-config-name rstudio-image-config
  5. 删除 SageMaker 映像,这也会删除所有映像版本。Amazon ECR 中由映像版本表示的容器映像不会被删除。

    aws sagemaker delete-image \ --image-name rstudio-image