---
title: "A revision that deployed weeks ago now fails to pull its image | Proofline"
description: "Ask ECR for the exact digest the running service revision pinned."
url: https://proofline.sh/learn/ecr-lifecycle-policy-deleted-running-image/
---

[Learning center](/learn/)

# A revision that deployed weeks ago now fails to pull its image

Ask ECR for the exact digest the running service revision pinned. If ECR no longer returns it and no new deployment started, the old revision lost its image, and the repository's lifecycle policy or a deletion is the next read.

Deployment failures The Proofline team November 22, 2026 8 min read

## A new failure from an old revision

The service has run the same task definition revision for weeks. Then a scale-out, a Spot interruption or a host replacement starts new tasks, and each one stops with `TaskFailedToStart` and a `CannotPullContainerError` that says the image was not found. Running tasks keep working, because they pulled their image when they started. Only tasks that must pull now fail.

Two situations produce this record:

-   **A release failed.** The revision references a tag or digest the registry never held, so ECS could not resolve it when the deployment started. The [image not found guide](/learn/ecs-cannotpullcontainer-image-not-found/) covers it.
-   **The revision lost its image.** The image existed when the revision was registered and has since been expired, archived or deleted in ECR, sometimes before the deployment's first pull. This is usually an old revision, but a lifecycle rule or a cleanup can remove the image of a deployment that started minutes ago too.

The age of the deployment is a hint. The digest the deployment resolved, and a record of its removal, decide which case you have.

The fix differs. Rolling back helps the first. For the second it helps only when the previous revision's image still exists, and when the failing revision is the long-running one there is nothing earlier to roll back to. [CannotPullContainer task errors](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_cannot_pull_image.html)

## Decide which deployment the failing tasks belong to

Use a read-only profile and replace the uppercase placeholders.

```
aws ecs describe-services \
  --profile PROFILE --region REGION --cluster CLUSTER --services SERVICE \
  --query 'services[0].{deployments:deployments[].{id:id,status:status,definition:taskDefinition,created:createdAt,rollout:rolloutState}}' \
  --output json --no-cli-pager

aws ecs describe-tasks \
  --profile PROFILE --region REGION --cluster CLUSTER --tasks STOPPED_TASK_ARN \
  --query 'tasks[].{deployment:startedBy,definition:taskDefinitionArn,code:stopCode,reason:stoppedReason,stopped:stoppedAt}' \
  --output json --no-cli-pager
```

`startedBy` on a service task holds its deployment ID. If it matches a `PRIMARY` deployment created weeks ago, and no other deployment is listed, the failing tasks belong to the old revision. [Deployment fields](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Deployment.html) · [Task fields](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Task.html)

## Find the digest the revision pinned

By default, ECS resolves each image tag to a digest when a deployment starts and uses that digest for every task the deployment starts later, scale-out included. A tag pushed again since then does not change what the service pulls. The resolved digest is in the service revision. [Container image resolution](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html) · [ContainerImage](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerImage.html)

```
aws ecs list-service-deployments \
  --profile PROFILE --region REGION --cluster CLUSTER --service SERVICE --max-results 5 \
  --query 'serviceDeployments[].{status:status,started:startedAt,finished:finishedAt,revision:targetServiceRevisionArn}' \
  --output json --no-cli-pager

aws ecs describe-service-revisions \
  --profile PROFILE --region REGION --service-revision-arns SERVICE_REVISION_ARN \
  --query 'serviceRevisions[].{definition:taskDefinition,created:createdAt,images:containerImages[].{container:containerName,image:image,digest:imageDigest}}' \
  --output json --no-cli-pager
```

Service revisions exist only for deployments created on or after October 25, 2024. For an older deployment, read `containers[].imageDigest` from a task of that deployment that is still running. If the container definition sets `versionConsistency` to `disabled`, ECS pulls the tag as written, and the question becomes whether that tag still exists. [DescribeServiceRevisions](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeServiceRevisions.html) · [ContainerDefinition](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html)

## Ask ECR for that digest

```
aws ecr batch-get-image \
  --profile PROFILE --region IMAGE_REGION --registry-id IMAGE_ACCOUNT \
  --repository-name REPOSITORY --image-ids imageDigest=sha256:DIGEST \
  --query '{found:images[].imageId,failures:failures[].{code:failureCode,reason:failureReason}}' \
  --output json --no-cli-pager

aws ecr describe-images \
  --profile PROFILE --region IMAGE_REGION --registry-id IMAGE_ACCOUNT \
  --repository-name REPOSITORY --filter imageStatus=ARCHIVED \
  --query 'imageDetails[?imageDigest==`"sha256:DIGEST"`].{tags:imageTags,pushed:imagePushedAt,lastPull:lastRecordedPullTime,archived:lastArchivedAt,status:imageStatus}' \
  --output json --no-cli-pager
```

A failure with code `ImageNotFound` means the repository no longer holds that digest as an active image. ECR can also move images to an archive storage class, and `describe-images` returns only `ACTIVE` images unless you filter on `imageStatus`, so the second command checks whether the digest was archived rather than deleted. An archived image cannot be pulled until it is restored. [ImageFailure](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_ImageFailure.html) · [DescribeImagesFilter](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_DescribeImagesFilter.html) · [Archiving images](https://docs.aws.amazon.com/AmazonECR/latest/userguide/archive_restore_image.html)

## Read the lifecycle policy and the deletion record

```
aws ecr get-lifecycle-policy \
  --profile PROFILE --region IMAGE_REGION --registry-id IMAGE_ACCOUNT --repository-name REPOSITORY \
  --query '{lastEvaluated:lastEvaluatedAt,policy:lifecyclePolicyText}' \
  --output json --no-cli-pager
```

A lifecycle rule selects images by tag status (`tagged`, `untagged` or `any`), optional tag patterns, and a count type: `imageCountMoreThan`, `sinceImagePushed`, `sinceImagePulled` or `sinceImageTransitioned`. Its action expires the image or transitions it to archive. No rule property refers to whether a task definition or a service uses the image. ECR applies the action within 24 hours of an image meeting the rule, and `lastEvaluatedAt` records the last run. [Lifecycle policy properties](https://docs.aws.amazon.com/AmazonECR/latest/userguide/lifecycle_policy_parameters.html) · [Lifecycle policies](https://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html) · [GetLifecyclePolicy](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_GetLifecyclePolicy.html)

Three rule shapes catch a revision that stays deployed. A count rule such as "keep the last 20 images" expires a stable release once twenty newer builds are pushed. An `untagged` rule expires a pinned digest after its tag moved to a newer image. A `sinceImagePulled` rule reads `lastRecordedPullTime`, which a service that rarely starts new tasks may not refresh for weeks.

CloudTrail separates a lifecycle action from a person or tool. ECR records each lifecycle action as a `PolicyExecutionEvent`, and a direct deletion as a `BatchDeleteImage` call with the caller's identity. Event history covers the last 90 days in the Region. [ECR CloudTrail logging](https://docs.aws.amazon.com/AmazonECR/latest/userguide/logging-using-cloudtrail.html) · [lookup-events](https://docs.aws.amazon.com/cli/latest/reference/cloudtrail/lookup-events.html)

```
aws cloudtrail lookup-events \
  --profile PROFILE --region IMAGE_REGION \
  --lookup-attributes AttributeKey=EventName,AttributeValue=PolicyExecutionEvent \
  --start-time START --end-time END \
  --query 'Events[].{time:EventTime,event:CloudTrailEvent}' \
  --output json --no-cli-pager
```

Search the `event` JSON for the digest. Repeat with `AttributeValue=BatchDeleteImage`. ECR splits an action on ten or more images into several events, so check every event in the window. Removing an image's last tag with `BatchDeleteImage` deletes the image too. [BatchDeleteImage](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_BatchDeleteImage.html)

## What each result means

| Pinned digest | Digest in ECR | Record | Reading |
| --- | --- | --- | --- |
| None resolved, and no task of the deployment ever ran | `ImageNotFound` | None for the tag in CloudTrail's 90-day event history | The tag never resolved: a release failure, unless the tag could have been pushed and removed before that history begins; see [image not found](/learn/ecs-cannotpullcontainer-image-not-found/) |
| None resolved, and no task of the deployment ever ran | `ImageNotFound` | `PolicyExecutionEvent` or `BatchDeleteImage` for the tag's image | Removed before the deployment's first pull; the reference was right, so restore or push the image rather than fix the revision |
| None resolved, but tasks of the deployment ran | The tag the failing task pulled: `ImageNotFound` | `PolicyExecutionEvent` or `BatchDeleteImage` for the tag or the earlier digest | Resolution fell back to the tag, which each new task pulls as written; the tag's image was removed after earlier tasks pulled it |
| Resolved | `ImageNotFound`, not archived | `PolicyExecutionEvent` naming the digest | A lifecycle rule expired the image after the deployment started |
| Resolved | `ImageNotFound`, not archived | `BatchDeleteImage` by a person or role | A deletion outside the policy |
| Resolved | `ImageNotFound`, not archived | None in the window | Removed, cause not on record here; widen the CloudTrail window or check the registry account |
| Resolved | Found with `imageStatus` `ARCHIVED` | `lastArchivedAt` set | An archive rule moved it; it can be restored |
| Resolved | Found, `ACTIVE` | None | The image is present; read the reason again for access or [network errors](/learn/ecs-image-pull-timeout-private-subnet/) |

A missing digest alone does not prove a release failure: AWS documents that after three failed resolution attempts a deployment without the circuit breaker continues with the tag, and its tasks can run until the image goes. In that case each task pulls the tag as written, so an earlier task's `containers[].imageDigest` shows only what the tag named when that task started, not what a replacement pulls; the tag may have moved since. Ask ECR for the tag itself, and search the removal records below for it and for the earlier digest, before you classify it. These rows hold for a deployment of any age. A deployment that started minutes ago and pinned a digest that ECR has since expired follows the lifecycle rows, not the release-failure row.

## Restore the service, then the rule

An archived image returns with `update-image-storage-class` and a target of `STANDARD`, which ECR documents as completing within about 20 minutes. This is a change. [Restoring an image](https://docs.aws.amazon.com/AmazonECR/latest/userguide/restore-image.html)

An expired image is gone. Pushing the identical manifest again restores the same digest; a rebuild usually produces a different manifest and so a different digest, which the pinned revision will not use. In that case start a new deployment, which resolves the tag again, and check first what the tag names now, since it may be a newer build than the one that was running.

Then change the rule so that images still deployed fall outside it, for example by tagging releases with a prefix the expiry rule excludes. Before applying the policy, run `start-lifecycle-policy-preview` with the new text and read `get-lifecycle-policy-preview --image-ids imageDigest=sha256:DIGEST` for the replacement digest: a result with an `action` and `appliedRulePriority` names the rule that would act on it. The preview changes no images. [GetLifecyclePolicyPreview](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_GetLifecyclePolicyPreview.html)

## An illustrative incident, two outcomes

These records are fictional. `checkout` has run `checkout:41` since October 2, 2026, pinned to digest `sha256:4f1e...`. On November 20 a Spot interruption replaces two tasks, and both replacements fail to pull. No deployment started after October 2.

-   **Outcome A.** `batch-get-image` returns `ImageNotFound`. The policy keeps the newest 30 tagged images, and the CI job pushes a build per merge; the 31st newer build landed on November 19. A `PolicyExecutionEvent` that night names the digest. The image is gone; deploy a current release on purpose, then exclude release tags from the count rule.
-   **Outcome B.** The digest appears under `imageStatus=ARCHIVED`, archived November 3 by a rule that archives images not pulled for 30 days. `checkout` had started no task since October 2. Restore it, and the pinned revision can pull again without a new deployment. Then widen the rule's window or exclude release tags.

## Where this check misleads

`lastRecordedPullTime` is refreshed at least once every 24 hours, so it gives the day of the last pull, not the minute. A tag that exists today says nothing about the pinned digest; always look up the digest. CloudTrail event history reaches back 90 days, and older deletions need a trail you kept. For which signatures belong to the release and which to the environment, see the [signature table](/learn/aws-deployment-failure-signatures/). [ImageDetail](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_ImageDetail.html)

## Questions

### Does an ECR lifecycle policy skip images that ECS is using?

The rule properties select by tag, count, push time and pull time, and none of them refers to ECS. Exclude deployed images through tags or count settings, and check the preview for the digests your services pin.

### Why does a rollback not fix an image deleted by a lifecycle policy?

The failing tasks already run the old revision. Rolling back to it starts more tasks that pull the same missing digest. Restore the image or deploy a revision whose image exists.

### Can I pull an archived ECR image?

No. Pulls fail until the image is restored to the standard storage class, which ECR documents as taking up to 20 minutes.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [CannotPullContainerError on ECS: missing image, denial or timeout](/learn/ecs-cannotpullcontainer-image-not-found/)
    
    Deployment failures The Proofline team November 22, 2026 7 min read
    
-   ### [ECS image pull times out in a private subnet: NAT or endpoints](/learn/ecs-image-pull-timeout-private-subnet/)
    
    Network outages The Proofline team November 22, 2026 6 min read
