Menu
Amazon ECR
User Guide (API Version 2015-09-21)

Deleting an Image

If you are done using an image, you can delete it from your repository. You can delete an image using the AWS Management Console, or the AWS CLI.

Note

If you are done with a repository, you can delete the entire repository and all of the images within it. For more information, see Deleting a Repository.

To delete an image with the AWS Management Console

  1. Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.

  2. From the navigation bar, choose the region that contains the image to delete.

  3. In the navigation pane, choose Repositories.

  4. On the Repositories page, choose the repository that contains the image to delete.

  5. On the All repositories: repository_name page, select the box to the left of the images to delete and choose Delete.

  6. In the Delete image(s) dialog box, verify that the selected images should be deleted and choose Delete.

To delete an image with the AWS CLI

  1. List the images in your repository so that you can identify them by image tag or digest.

    Copy
    $ aws ecr list-images --repository-name my-repo { "imageIds": [ { "imageTag": "latest", "imageDigest": "sha256:4f70ef7a4d29e8c0c302b13e25962d8f7a0bd304c7c2c1a9d6fa3e9de6bf552d" } ] }
  2. (Optional) Delete any unwanted tags for the image by specifying the tag of the image you want to delete.

    Note

    When you delete the last tag for an image, the image is deleted.

    Copy
    $ aws ecr batch-delete-image --repository-name my-repo --image-ids imageTag=latest { "failures": [], "imageIds": [ { "imageTag": "latest", "imageDigest": "sha256:4f70ef7a4d29e8c0c302b13e25962d8f7a0bd304c7c2c1a9d6fa3e9de6bf552d" } ] }
  3. Delete the image by specifying the digest of the image to delete.

    Note

    When you delete an image by referencing its digest, the image and all of its tags are deleted.

    Copy
    $ aws ecr batch-delete-image --repository-name my-repo --image-ids imageDigest=sha256:4f70ef7a4d29e8c0c302b13e25962d8f7a0bd304c7c2c1a9d6fa3e9de6bf552d { "failures": [], "imageIds": [ { "imageTag": "latest", "imageDigest": "sha256:4f70ef7a4d29e8c0c302b13e25962d8f7a0bd304c7c2c1a9d6fa3e9de6bf552d" } ] }