Amazon ECR "name unknown: The repository ... does not exist" in CI
Unlike some registries, ECR does not create a repository on first push. If the repo name in your tag has not been created in that account and region, the push fails with "name unknown: The repository ... does not exist". Create it once with the CLI or Terraform.
What this error means
docker push to ECR fails with "name unknown: The repository with name 'app' does not exist in the registry with id '123456789012'".
name unknown: The repository with name 'app' does not exist in the registry
with id '123456789012'Common causes
The repository was never created in ECR
ECR requires the repository to exist before a push. A new image name has no repo, so the push is rejected.
Right name, wrong account or region
The repo exists, but the tag points at a different registry id or region where it does not, so ECR reports it missing.
How to fix it
Create the repository before pushing
- Create the ECR repository in the correct account and region.
- Confirm the tag host and repo name match exactly.
- Re-run the push.
aws ecr create-repository --repository-name app --region us-east-1Manage the repository as code
Define the ECR repository in Terraform/CloudFormation so it always exists before CI pushes.
resource "aws_ecr_repository" "app" {
name = "app"
}How to prevent it
- Create ECR repositories ahead of the first push.
- Verify the registry id and region in the image tag.
- Provision repositories via IaC, not ad hoc.