Menu
Amazon EC2 Container Registry
API Reference (API Version 2015-09-21)

BatchDeleteImage

Deletes a list of specified images within a specified repository. Images are specified with either imageTag or imageDigest.

You can remove a tag from an image by specifying the image's tag in your request. When you remove the last tag from an image, the image is deleted from your repository.

You can completely delete an image (and all of its tags) by specifying the image's digest in your request.

Request Syntax

Copy
{ "imageIds": [ { "imageDigest": "string", "imageTag": "string" } ], "registryId": "string", "repositoryName": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

imageIds

A list of image ID references that correspond to images to delete. The format of the imageIds reference is imageTag=tag or imageDigest=digest.

Type: Array of ImageIdentifier objects

Array Members: Minimum number of 1 item. Maximum number of 100 items.

Required: Yes

registryId

The AWS account ID associated with the registry that contains the image to delete. If you do not specify a registry, the default registry is assumed.

Type: String

Pattern: [0-9]{12}

Required: No

repositoryName

The repository that contains the image to delete.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 256.

Pattern: (?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)*

Required: Yes

Response Syntax

Copy
{ "failures": [ { "failureCode": "string", "failureReason": "string", "imageId": { "imageDigest": "string", "imageTag": "string" } } ], "imageIds": [ { "imageDigest": "string", "imageTag": "string" } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

failures

Any failures associated with the call.

Type: Array of ImageFailure objects

imageIds

The image IDs of the deleted images.

Type: Array of ImageIdentifier objects

Array Members: Minimum number of 1 item. Maximum number of 100 items.

Errors

For information about the errors that are common to all actions, see Common Errors.

InvalidParameterException

The specified parameter is invalid. Review the available parameters for the API request.

HTTP Status Code: 400

RepositoryNotFoundException

The specified repository could not be found. Check the spelling of the specified repository and ensure that you are performing operations on the correct registry.

HTTP Status Code: 400

ServerException

These errors are usually caused by a server-side issue.

HTTP Status Code: 500

Examples

In the following example or examples, the Authorization header contents (AUTHPARAMS) must be replaced with an AWS Signature Version 4 signature. For more information about creating these signatures, see Signature Version 4 Signing Process in the AWS General Reference.

You only need to learn how to sign HTTP requests if you intend to manually create them. When you use the AWS Command Line Interface (AWS CLI) or one of the AWS SDKs to make requests to AWS, these tools automatically sign the requests for you with the access key that you specify when you configure the tools. When you use these tools, you don't need to learn how to sign requests yourself.

Example

This example deletes an image in the ubuntu repository with the imageTag value of xenial.

Sample Request

Copy
POST / HTTP/1.1 Host: ecr.us-west-2.amazonaws.com Accept-Encoding: identity Content-Length: 66 X-Amz-Target: AmazonEC2ContainerRegistry_V20150921.BatchDeleteImage X-Amz-Date: 20161216T193711Z User-Agent: aws-cli/1.11.22 Python/2.7.12 Darwin/16.3.0 botocore/1.4.79 Content-Type: application/x-amz-json-1.1 Authorization: AUTHPARAMS { "repositoryName": "ubuntu", "imageIds": [ { "imageTag": "xenial" } ] }

Sample Response

Copy
HTTP/1.1 200 OK Server: Server Date: Fri, 16 Dec 2016 19:37:11 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 138 Connection: keep-alive x-amzn-RequestId: 09cc7023-c3c7-11e6-8acf-61b7dd8abe56 { "failures": [], "imageIds": [ { "imageDigest": "sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a", "imageTag": "xenial" } ] }

Example

This example deletes an image (and all of its tags) in the ubuntu repository with the imageDigest value of sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a.

Sample Request

Copy
POST / HTTP/1.1 Host: ecr.us-west-2.amazonaws.com Accept-Encoding: identity Content-Length: 134 X-Amz-Target: AmazonEC2ContainerRegistry_V20150921.BatchDeleteImage X-Amz-Date: 20161216T194250Z User-Agent: aws-cli/1.11.22 Python/2.7.12 Darwin/16.3.0 botocore/1.4.79 Content-Type: application/x-amz-json-1.1 Authorization: AUTHPARAMS { "repositoryName": "ubuntu", "imageIds": [ { "imageDigest": "sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a" } ] }

Sample Response

Copy
HTTP/1.1 200 OK Server: Server Date: Fri, 16 Dec 2016 19:42:50 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 248 Connection: keep-alive x-amzn-RequestId: d441a9f6-c3c7-11e6-8acf-61b7dd8abe56 { "failures": [], "imageIds": [ { "imageDigest": "sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a", "imageTag": "xenial" }, { "imageDigest": "sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a", "imageTag": "latest" } ] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: