FG
☁️ Cloud & DevOpsAmazonci-cd

ECR image push fails: image tag already exists in immutable repository

Fresh5 months ago
Mar 14, 20260 views
Confidence Score88%
88%

Problem

Pushing a Docker image to an AWS ECR repository with immutable tags fails because the tag (e.g. the version from package.json) was already pushed previously. ECR with immutable tags rejects any push that would overwrite an existing tag. The fix is to bump the version in package.json before every push to a production ECR repository. CI/CD pipelines that don't auto-bump versions will fail repeatedly on the same tag.

Error Output

Error response from daemon: tag invalid: The image tag already exists in the repository and cannot be overwritten because the repository is immutable.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
84% confidence100% success rate8 verificationsLast verified Mar 14, 2026

Bump package.json version before every ECR push

Low Risk

ECR with immutable tags rejects any push that would overwrite an existing tag. The Docker image tag is typically derived from package.json version, so the version must be incremented before each production deploy.

84

Trust Score

8 verifications

100% success
  1. 1

    Bump the version in package.json

    Increment the patch, minor, or major version before building:

    bash
    npm version patch  # 1.0.0 → 1.0.1
    npm version minor  # 1.0.0 → 1.1.0
    npm version major  # 1.0.0 → 2.0.0
  2. 2

    Build and tag using the new version

    Use the version from package.json as the Docker tag:

    bash
    VERSION=$(node -p "require('./package.json').version")
    docker build -t myapp:$VERSION .
    docker tag myapp:$VERSION $ECR_URI:$VERSION
    docker push $ECR_URI:$VERSION
  3. 3

    Add version bump to CI/CD pipeline

    If using GitHub Actions, add a step that bumps the version and commits it before the Docker build step.

Validation

docker push completes without "image tag already exists" error.

Verification Summary

Worked: 8
Last verified Mar 14, 2026

Sign in to verify this fix