Clean up image resources
This guide shows how to clean up RStudio image resources that you created in the previous sections. To delete an image, complete the following steps using either the SageMaker AI console or the AWS CLI, as shown in this guide.
-
Detach the image and image versions from your Amazon SageMaker AI domain.
-
Delete the image, image version, and app image config.
After you've completed these steps, you can delete the container image and repository from Amazon ECR. For more information about how to delete the container image and repository, see Deleting a repository.
Clean up resources from the SageMaker AI console
When you detach an image from a domain, all versions of the image are detached. When an image is detached, all users of the domain lose access to the image versions.
To detach an image
-
Open the Amazon SageMaker AI console at https://console.aws.amazon.com/sagemaker/
. -
On the left navigation pane, choose Admin configurations.
-
Under Admin configurations, choose domains.
-
Select the desired domain.
-
Choose Environment.
-
Under Custom images attached to domain, choose the image and then choose Detach.
-
(Optional) To delete the image and all versions from SageMaker AI, select Also delete the selected images .... This does not delete the associated images from Amazon ECR.
-
Choose Detach.
Clean up resources from the AWS CLI
To clean up resources
-
Detach the image and image versions from your domain by passing an empty custom image list to the domain. Open the
update-domain-input.json
file that you created in Attach the SageMaker AI image to your current domain. -
Delete the
RSessionAppSettings
custom images and then save the file. Do not modify theKernelGatewayAppSettings
custom images.{ "DomainId": "d-xxxxxxxxxxxx", "DefaultUserSettings": { "KernelGatewayAppSettings": { "CustomImages": [ ], ... }, "RSessionAppSettings": { "CustomImages": [ ], "DefaultResourceSpec": { } ... } } }
-
Use the domain ID and default user settings file to update your domain.
aws sagemaker update-domain \ --domain-id
<d-xxxxxxxxxxxx>
\ --cli-input-json file://update-domain-input.jsonResponse:
{ "DomainArn": "arn:aws:sagemaker:us-east-2:acct-id:domain/d-xxxxxxxxxxxx" }
-
Delete the app image config.
aws sagemaker delete-app-image-config \ --app-image-config-name rstudio-image-config
-
Delete the SageMaker AI image, which also deletes all image versions. The container images in Amazon ECR that are represented by the image versions are not deleted.
aws sagemaker delete-image \ --image-name rstudio-image