ECR docker push "denied: Not Authorized to Perform ecr:InitiateLayerUpload", Fixed: Why Login Succeeds but Push Fails, the Exact Push Policy, ReadOnly vs PowerUser, Cross-Account Repositories and Explicit Denies
"denied: User: arn:aws:... is not authorized to perform: ecr:InitiateLayerUpload on resource: arn:aws:ecr:...:repository/NAME because no identity-based policy allows the ecr:InitiateLayerUpload action" means docker push reached Amazon ECR, logged in fine, and was refused at the first write. The identity doing the push (your IAM user, or the role your CI runs as) has no permission to upload to that repository. The fix is to give it the push actions: ecr:InitiateLayerUpload, ecr:UploadLayerPart, ecr:CompleteLayerUpload, ecr:BatchCheckLayerAvailability, ecr:PutImage and ecr:BatchGetImage on the repository's ARN, plus ecr:GetAuthorizationToken on *. Here is why so many people are sure their permissions are fine: the most common read-only policy lets you log in and check layers, so everything looks healthy until the upload starts. AmazonEC2ContainerRegistryReadOnly includes GetAuthorizationToken and BatchCheckLayerAvailability, so docker login prints "Login Succeeded" and the push gets through its first step before failing at InitiateLayerUpload, the first action that writes. The action named in the error is not the only one you are missing; it is just the first one Docker tried.
Jake's shop booking app is built and pushed to ECR by a GitHub Actions workflow Ethan wrote last spring. It pushed fine for months. On Tuesday Ethan moved the workflow to a new, "least privilege" role his security checklist recommended, and the next build ended with denied: ... is not authorized to perform: ecr:InitiateLayerUpload. The login step was green. The build step was green. Only the push failed. "So the new role can see the shelf," Jake said, "but it can't put anything on it." That turned out to be exactly right.
New to ECR? Our plain-English ECR guide explains registries, repositories and image tags in about ten minutes. Every command below works on Windows, macOS and Kali Linux with the AWS CLI v2 and Docker installed.
Read the error: who, where, and which policy said no
The message is long, but it has exactly three parts, and each one answers a question:
denied: User: arn:aws:sts::111122223333:assumed-role/github-deploy/GitHubActions is not authorized to perform: ecr:InitiateLayerUpload on resource: arn:aws:ecr:us-east-1:111122223333:repository/shop-booking because no identity-based policy allows the ecr:InitiateLayerUpload action
- "User: arn:..." is the identity that tried to push.
:user/nameis an IAM user with access keys;:assumed-role/role-name/sessionis a role, which is what CI systems, EC2 instances and SSO sessions use. This is the identity you have to fix, so check it is the one you expected. Many hours have been lost editing the policy of a role that was not the one pushing. - "on resource: arn:aws:ecr:REGION:ACCOUNT:repository/NAME" is where the push was going: the Region, the account that owns the registry, and the repository name. A typo in the repository name, a different Region or a different account number here changes everything about the fix.
- The ending tells you which kind of policy refused the request. This is the most useful part, and it is easy to skip:
| The error ends with | What it means | Fix |
|---|---|---|
| because no identity-based policy allows the ... action | Nothing attached to the user or role allows the push | Add the push policy |
| because no resource-based policy allows the ... action | Cross-account push: the repository's own policy does not let your account in | Repository policy |
| with an explicit deny in a service control policy | An AWS Organizations SCP blocks it, for that account or Region | Ask the org admin |
| with an explicit deny in a resource-based policy | The repository policy has a Deny that matches you | Edit the repository policy |
| because no permissions boundary allows the ... action | The role has a permissions boundary that leaves ECR out | Extend the boundary |
| with an explicit deny in an identity-based policy | A Deny statement attached to the user or role | Find and narrow the Deny |
If you are not sure which identity your terminal or CI job is using, ask AWS directly with the same credentials the push uses:
aws sts get-caller-identity
The Arn it prints should match the ARN after "User:" in the error. If it does not, your Docker credentials and your AWS CLI credentials point at different identities, which happens when docker login was run with one profile and you are now checking another.
Why the error names InitiateLayerUpload: what docker push actually does
A push is not one request; it is a short conversation with the registry, and each step needs its own permission. For every image, Docker does roughly this:
- Log in with a token from
ecr:GetAuthorizationToken(that is whataws ecr get-login-passwordfetches). - Ask which layers the registry already has with
ecr:BatchCheckLayerAvailability, so it only uploads the new ones. - Start an upload for each missing layer with
ecr:InitiateLayerUpload. - Send the layer in parts with
ecr:UploadLayerPart, then finish withecr:CompleteLayerUpload. - Write the image manifest and tag with
ecr:PutImage.
Steps 1 and 2 are reads, and the popular AmazonEC2ContainerRegistryReadOnly managed policy allows both. Step 3 is the first write. So with a read-only policy, the login succeeds, the layer check succeeds, and the push stops at step 3 with exactly this error. That also means the error is not telling you that InitiateLayerUpload is the only permission you lack. Add it alone and the next push fails at UploadLayerPart, then at PutImage. Add all five write actions at once.
One special case: if every layer already exists in the repository (you are pushing a new tag for an image that is already there), Docker can skip steps 3 and 4 entirely, and the failure moves to ecr:PutImage. Same cause, same fix.
"So it isn't one missing permission," Jake said. "It's a missing set," said Ethan, "and the error only shows you the first card in the set."
The policy that fixes it
Attach this policy to the user or role named in the error. It allows pushing (and pulling) to one repository, which is what most CI roles need. Replace the Region, account ID and repository name with the values from the "on resource:" part of your error.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PushToOneRepository",
"Effect": "Allow",
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:PutImage",
"ecr:BatchGetImage"
],
"Resource": "arn:aws:ecr:us-east-1:111122223333:repository/shop-booking"
},
{
"Sid": "LoginToTheRegistry",
"Effect": "Allow",
"Action": "ecr:GetAuthorizationToken",
"Resource": "*"
}
]
}
Two details in that policy cause most failed fixes:
GetAuthorizationTokenmust have"Resource": "*". It is a registry-level action, not a repository-level one. If you put it in the same statement as the repository ARN, login breaks instead, with a different denied message.- The repository ARN must match exactly, including any namespace in the name. A repository called
shop/bookinghas the ARN...:repository/shop/booking. To cover a whole team's repositories, use a wildcard such as...:repository/shop/*, or...:repository/*for every repository in that Region and account.
To apply it from the CLI as an inline policy on a role:
# save the JSON above as ecr-push.json, then: aws iam put-role-policy --role-name github-deploy --policy-name ecr-push-shop-booking --policy-document file://ecr-push.json # for an IAM user instead: aws iam put-user-policy --user-name build-bot --policy-name ecr-push-shop-booking --policy-document file://ecr-push.json
IAM changes usually apply within seconds, occasionally a little longer. Log in again and push:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 111122223333.dkr.ecr.us-east-1.amazonaws.com docker push 111122223333.dkr.ecr.us-east-1.amazonaws.com/shop-booking:latest
If you are new to reading policies like this one, our IAM policy JSON guide walks through Effect, Action and Resource line by line.
How to push an image to ECR, start to finish
If you are setting up a push for the first time, or rebuilding one that broke, this is the whole sequence. Each step fails in its own recognizable way, so it doubles as a checklist.
- Create the repository (once). The name you choose here is the name in the image tag and in the policy ARN:
aws ecr create-repository --repository-name shop-booking --region us-east-1 --image-tag-mutability IMMUTABLE
- Log Docker in to the registry, in the repository's Region. The username is always the literal word
AWS:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 111122223333.dkr.ecr.us-east-1.amazonaws.com
On Windows PowerShell the same pipe works. "Login Succeeded" here proves only that your identity has ecr:GetAuthorizationToken, not that it can push.
- Tag the local image with the full registry address, repository name and a tag:
docker build -t shop-booking . docker tag shop-booking:latest 111122223333.dkr.ecr.us-east-1.amazonaws.com/shop-booking:2026-10-17
- Push it:
docker push 111122223333.dkr.ecr.us-east-1.amazonaws.com/shop-booking:2026-10-17
- Confirm it arrived:
aws ecr describe-images --repository-name shop-booking --region us-east-1 --query "imageDetails[].imageTags"
Where each step fails: step 1 needs ecr:CreateRepository (pipelines often lack it, which is fine if the repository already exists); step 2 fails with a denied login if GetAuthorizationToken is missing or placed on the wrong resource; step 4 is where this page's error appears; and a tag that points at a different account, Region or name than the repository you created gives name unknown instead. If you build on a Mac with Apple silicon for servers that run on x86, add --platform linux/amd64 to docker build; that is not a permissions problem, but it is the next thing that bites after the push works.
The AWS managed policies: which ones can push
If you would rather attach a ready-made policy, ECR has four for people and workloads. Only two of them can push:
| Managed policy | Can log in | Can pull | Can push | Use it for |
|---|---|---|---|---|
| AmazonEC2ContainerRegistryReadOnly | Yes | Yes | No | Servers and tasks that only pull |
| AmazonEC2ContainerRegistryPullOnly | Yes | Yes, including pull-through cache | No | Runtime pulls (added October 2024) |
| AmazonEC2ContainerRegistryPowerUser | Yes | Yes | Yes, to every repository | Build systems; cannot delete repositories or change their policies |
| AmazonEC2ContainerRegistryFullAccess | Yes | Yes | Yes | Administrators only |
The PowerUser policy is the one-command fix (aws iam attach-role-policy --role-name github-deploy --policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser), and it is a reasonable choice for a build account. It applies to every repository, though, so a single CI role with PowerUser can overwrite any image in the account. If several apps share an account, the one-repository policy above is the safer long-term answer. Ethan's new "least privilege" role had ReadOnly, which was least privilege for a server that pulls and exactly wrong for a pipeline that pushes.
Pushing to a repository in another AWS account
When the account ID in "on resource:" is different from the account in "User:", you are pushing across accounts, and two policies must agree:
- In your account, the identity policy on your user or role must allow the push actions on the other account's repository ARN (the policy above, with the other account's ID in the Resource).
- In the repository's account, the repository policy must allow your account or your role. If it does not, the error ends with "because no resource-based policy allows" instead.
The owner of the repository adds a statement like this, in ECR > Repositories > the repository > Permissions, or from the CLI:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPushFromBuildAccount",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::444455556666:role/github-deploy" },
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:PutImage",
"ecr:BatchGetImage"
]
}
]
}
aws ecr set-repository-policy --repository-name shop-booking --policy-text file://repo-policy.json --region us-east-1 aws ecr get-repository-policy --repository-name shop-booking --region us-east-1
A repository policy has no Resource line; it always applies to the repository it is attached to. Be careful with set-repository-policy: it replaces the whole policy, so read the current one first and merge your statement into it, or you may remove someone else's access.
Then log in to the registry of the account that owns the repository, not your own: for example docker login to 111122223333.dkr.ecr.us-east-1.amazonaws.com with a password from aws ecr get-login-password --region us-east-1. Your own credentials fetch the token; the repository policy decides what you can do with it there. The Region must match the repository's Region.
When the error says "explicit deny"
An explicit deny beats any number of allows. If the error ends with "with an explicit deny in ...", adding permissions to your role will not change anything; the deny has to be found and changed, usually by whoever owns it.
- Service control policy (SCP): your organization blocks the action for this account, often outside approved Regions or for all writes in a production account. Only an AWS Organizations administrator can change it. Our AWS Organizations guide explains how SCPs sit above every policy in the account.
- Repository policy: the repository has a Deny statement, for example one that only allows pushes from a specific pipeline role or blocks all pushes to a
prodrepository. Read it withaws ecr get-repository-policy. - Permissions boundary: the role has a boundary that does not include ECR. The boundary sets the maximum a role can do, so ECR actions must be inside it too.
- Identity policy: a Deny attached to the user or role itself, often from a shared "deny dangerous actions" policy.
Our explicit deny guide shows how to find which policy contains the Deny when the message does not say enough.
In GitHub Actions, CodeBuild, Jenkins and GitLab
CI is where this error lives, because CI runs as a role you set up once and rarely look at. The fix is always the same (give that role the push policy), but each system hides the role in a different place:
- GitHub Actions: the role is the
role-to-assumein theaws-actions/configure-aws-credentialsstep. The ARN in the error will beassumed-role/THAT-ROLE/GitHubActionsor similar. Check that the workflow uses the role you edited, especially if different branches or environments use different roles. Afterconfigure-aws-credentials, useaws-actions/amazon-ecr-loginto log in. - AWS CodeBuild: the push runs as the project's service role (Project > Edit > Environment > Service role). Older CodeBuild setups were often given only pull access for base images. Our CodeBuild COMMAND_EXECUTION_ERROR guide covers the build-log side of a failed push.
- Jenkins or GitLab runners on EC2: the push runs as the instance profile of the build server, unless access keys are set in the job. An instance profile with ReadOnly (so the server could pull base images) is a very common cause.
- Your laptop: it is whatever
aws sts get-caller-identityprints for the profile you used withget-login-password.
A useful habit for any pipeline: print aws sts get-caller-identity as the first AWS step. When a push fails, the log already shows which identity tried.
Other docker push errors that look similar
Not every failed push to ECR is this error. These come up next to it:
no basic auth credentialsor a bare HTTP 403: you are not logged in to that registry, or you logged in to a different Region. ECR login tokens are tied to one Region and last 12 hours. Runget-login-passwordagain with the repository's Region. On Docker for Windows, thewincredcredential helper has had a bug with ECR logins; removinghttps://from the registry address in the login command works around it.denied: Your authorization token has expired. Reauthenticate and try again.: the 12-hour login ran out mid-session. Our expired token guide covers automating the refresh.name unknown: The repository with name 'shop-booking' does not exist in the registry with id '111122223333': the repository has not been created, or you tagged the image with a different name, account or Region. Create it withaws ecr create-repository --repository-name shop-booking, or fix the tag.tag invalid: The image tag 'latest' already exists in the 'shop-booking' repository and cannot be overwritten because the repository is immutable.: tag immutability is on. Push a new tag (a version or commit SHA) instead of reusing one.- Endless "Retrying in 5 seconds" on a layer: often a network or proxy problem with large layers, not permissions. Pushes from a private subnet need a route to ECR and to S3 (through a NAT gateway or VPC endpoints).
For IT admins: making pushes predictable
- Separate pull roles from push roles. Runtime roles (ECS tasks, EKS nodes, servers) get PullOnly or ReadOnly; only build pipelines get push. That way a compromised server cannot overwrite your images.
- Scope push to repositories. Give each pipeline the one-repository policy (or a namespace wildcard such as
repository/team-a/*) rather than PowerUser across the account. - Turn on tag immutability for release repositories, so a mistaken push can never replace a deployed tag.
- Use repository creation templates if teams create many repositories, so new repositories start with the right repository policy, encryption and lifecycle settings.
- Prefer OIDC roles in CI over long-term access keys stored as CI secrets, and check CloudTrail for denied
InitiateLayerUploadevents to spot misconfigured pipelines before developers report them.
Frequently asked questions
What does "not authorized to perform: ecr:InitiateLayerUpload" mean?
The identity pushing the image has no permission to start uploading layers to that ECR repository. Login and layer checks worked; the first write was refused. Add the ECR push actions to that user or role.
How do I push an image to ECR?
Create the repository, log in with aws ecr get-login-password piped to docker login --username AWS, tag the image as ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY:TAG, then docker push that tag and check it with aws ecr describe-images.
Which permissions does docker push to ECR need?
ecr:BatchCheckLayerAvailability, ecr:InitiateLayerUpload, ecr:UploadLayerPart, ecr:CompleteLayerUpload, ecr:PutImage and ecr:BatchGetImage on the repository ARN, plus ecr:GetAuthorizationToken on "*".
Why does docker login succeed but docker push is denied?
Login only needs ecr:GetAuthorizationToken, which read-only policies include. Pushing needs the write actions, which AmazonEC2ContainerRegistryReadOnly and PullOnly do not grant.
Can AmazonEC2ContainerRegistryReadOnly push images?
No. It allows login, layer checks and pulls, but not InitiateLayerUpload, UploadLayerPart, CompleteLayerUpload or PutImage. Use AmazonEC2ContainerRegistryPowerUser or a custom push policy.
Which AWS managed policy allows pushing to ECR?
AmazonEC2ContainerRegistryPowerUser allows push and pull to every repository but not deleting repositories or changing their policies. AmazonEC2ContainerRegistryFullAccess also allows push but is meant for administrators.
I added ecr:InitiateLayerUpload and now it fails on UploadLayerPart. Why?
The error only names the first missing action. A push needs InitiateLayerUpload, UploadLayerPart, CompleteLayerUpload and PutImage together, so add the full set at once.
Why does ecr:GetAuthorizationToken need Resource "*"?
It is a registry-level action that does not apply to a single repository. Put it in its own statement with "Resource": "*", or login fails.
How do I push to an ECR repository in another AWS account?
Allow the push actions on the other account's repository ARN in your identity policy, and have the repository owner add a repository policy that allows your account or role. Then log in to the other account's registry address.
What does "because no resource-based policy allows" mean in ECR?
It appears on cross-account pushes when the target repository's policy does not allow your account or role. The repository owner must add a statement for you with set-repository-policy.
What if the error says "explicit deny in a service control policy"?
An AWS Organizations SCP blocks the push for your account or Region. Adding allows to your role cannot override it; an organization administrator must change the SCP.
How do I fix this in GitHub Actions?
Find the role-to-assume in the configure-aws-credentials step and attach the ECR push policy to that role. Print aws sts get-caller-identity in the workflow to confirm which role is pushing.
How do I fix this in AWS CodeBuild?
Attach the push policy to the CodeBuild project's service role, shown under Environment in the project settings. CodeBuild pushes as that role, not as your user.
Does the repository name in the policy need to match exactly?
Yes, including namespaces: a repository named team/app has the ARN ending repository/team/app. Use a wildcard such as repository/team/* to cover several repositories.
How long do IAM changes take to apply for ECR?
Usually seconds. Log in again with aws ecr get-login-password and retry the push; if it still fails, check that you edited the role named in the error.
What is the difference between "no basic auth credentials" and this error?
"no basic auth credentials" means Docker is not logged in to that registry, or logged in for another Region. The InitiateLayerUpload error means you are logged in but not allowed to write.
Why does docker push say the repository does not exist?
"name unknown: The repository with name ... does not exist" means the repository was never created, or the image tag uses the wrong name, account or Region. Create it with aws ecr create-repository or fix the tag.
Can tag immutability cause a denied push?
It causes a different error, "tag invalid: The image tag ... already exists ... and cannot be overwritten because the repository is immutable." Push a new, unique tag instead.
For readers preparing for an AWS certification
We have been covering AWS certifications alongside our fixes, so here is a short extra for readers studying for one. If you only came for the fix, you already have it; feel free to skip this part.
Exams that test this topic: Developer – Associate (DVA-C03 from December 1, 2026) • DevOps Engineer – Professional (DOP-C02) • CloudOps Engineer – Associate (SOA-C03).
Here are the exam-style questions this topic tends to raise, with the reasoning you need to answer them:
1. Which permissions does a role need to push an image to ECR?
ecr:GetAuthorizationToken, BatchCheckLayerAvailability, InitiateLayerUpload, UploadLayerPart, CompleteLayerUpload and PutImage.
2. A pipeline in account A must push to a repository in account B. What is needed?
A repository policy in account B that allows account A, and matching IAM permissions in account A.
3. How long is an ECR login token valid?
12 hours.
4. Every pushed image must be scanned for vulnerabilities. What do you turn on?
Scan on push (basic scanning) or enhanced scanning with Amazon Inspector.
5. Images must also exist in a second Region. What do you configure?
ECR replication rules.
6. Images must be encrypted with your own key. When do you set it?
When you create the repository, by choosing KMS encryption with your key.
Exam codes and dates change often. Our AWS certification changes page keeps track of what is current.
Ethan replaced ReadOnly on the new role with a policy for the one repository the booking app uses, and the next build pushed in forty seconds. He kept the ReadOnly policy for the ECS task role, where it belonged all along. Jake asked whether the "least privilege" checklist had been wrong. "It was right," Ethan said. "It just didn't know which of my roles was the one doing the pushing."
📌 If you keep one line from this page
The ecr:InitiateLayerUpload error means the pushing identity can log in but cannot write: give the role named after "User:" all five push actions on the repository in "on resource:", plus GetAuthorizationToken on *, and check the ending for an explicit deny.
ReadOnly and PullOnly cannot push · PowerUser can · cross-account needs a repository policy too.
Revision note. Written October 17, 2026. "A chain is only as strong as its weakest link," the proverb says; a push is only as good as its last permission.