Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

Pulling a public image from public.ecr.aws returns 403

Your error

failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 3.8]: 403 Forbidden1 more line it can show

Fix it fast

Most common cause, 1 of 2

A forgotten ECR Public login is still attached to every pull

Remove the saved login for that host.

Fix
docker logout public.ecr.aws
docker pull public.ecr.aws/registry_alias/repository_name:image_tag
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

A docker pull or docker build from public.ecr.aws fails with 403 Forbidden or Your authorization token has expired when Docker still sends an ECR Public token from an earlier login. Those tokens last 12 hours, and an expired one even breaks anonymous pulls. Run docker logout public.ecr.aws, or log in again with aws ecr-public get-login-password --region us-east-1.

  • Applies to Docker Engine 29.10, Docker Buildx 0.39, AWS CLI 2.41, Amazon ECR Public
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Look for a saved entry for public.ecr.aws in the Docker client config of the user or runner that pulls. No entry means Docker pulls anonymously and the stale-token causes below do not apply. An entry you never meant to keep points to cause 1; an entry your pipeline writes on purpose points to cause 2.

Run this first
grep -n -A2 '"public.ecr.aws"' ~/.docker/config.json

Then find the line you see in this list and open its fix:

  1. 1A forgotten ECR Public login is still attached to every pullconfig.json lists public.ecr.aws, you only pull public images, and nothing in your setup logs in again
  2. 2A runner logged in once and kept the token past 12 hoursBuilds pass for a while after the runner boots or after a manual login, then every public.ecr.aws pull fails until someone logs in again

What does the error look like?

  • failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 3.8]: 403 Forbidden
  • Error response from daemon: pull access denied for public.ecr.aws/registry_alias/repository_name, repository does not exist or may require 'docker login': denied: Your authorization token has expired. Reauthenticate and try again.

Cause 1 of 2

A forgotten ECR Public login is still attached to every pull

You seeconfig.json lists public.ecr.aws, you only pull public images, and nothing in your setup logs in again

Check

When public.ecr.aws answers a pull for a public image with 403 or token expired, Docker is usually presenting a saved token that has run out. AWS documents that an expired token from a past login makes otherwise anonymous pulls fail. docker build fails the same way, since its [auth] step asks the Docker client for that saved login.

Check
grep -n -A2 '"public.ecr.aws"' ~/.docker/config.json

Fix

Remove the saved login for that host. The next pull goes out without a token, which is all a public repository needs.

Fix
docker logout public.ecr.aws
docker pull public.ecr.aws/registry_alias/repository_name:image_tag

Verify

The pull downloads the layers, and the config file no longer has a public.ecr.aws entry.

Verify
grep -c 'public.ecr.aws' ~/.docker/config.json

Confirmed by docs.aws.amazon.com

Did this fix it?

Cause 2 of 2

A runner logged in once and kept the token past 12 hours

You seeBuilds pass for a while after the runner boots or after a manual login, then every public.ecr.aws pull fails until someone logs in again

Check

Tokens returned by aws ecr-public get-login-password stay valid for 12 hours. A self-hosted CI runner, build VM or cron host that logged in at start-up keeps sending the same token long after it died. The file's time stamp shows the last time Docker saved any login; compare it with when the failures began.

Check
ls -l ~/.docker/config.json

Fix

Log in at the start of every job instead of once per machine. ECR Public logins through the AWS CLI must always target us-east-1, whatever Region your workloads run in.

Fix
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws

Verify

docker login reports success and the pull or build that failed now runs to the end.

Verify
docker pull public.ecr.aws/registry_alias/repository_name:image_tag

Confirmed by docs.aws.amazon.com

Did this fix it?

How do I stop it coming back?

  • Skip docker login for public.ecr.aws on machines that only pull public images; anonymous pulls need no token.
  • When a job does log in, end it with docker logout public.ecr.aws so the next job on a shared runner starts with a clean config.
  • Keep the us-east-1 login line inside the pipeline file, not in a runner boot script nobody sees.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Dispatch Pro, TaxiDex, Raheeb.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.