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 showFix it fast
Most common cause, 1 of 2A forgotten ECR Public login is still attached to every pull
Remove the saved login for that host.
docker logout public.ecr.aws
docker pull public.ecr.aws/registry_alias/repository_name:image_tagShort 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.
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.
grep -n -A2 '"public.ecr.aws"' ~/.docker/config.jsonThen find the line you see in this list and open its fix:
- 1A forgotten ECR Public login is still attached to every pull
config.json lists public.ecr.aws, you only pull public images, and nothing in your setup logs in again - 2A runner logged in once and kept the token past 12 hours
Builds 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 ForbiddenError 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.
grep -n -A2 '"public.ecr.aws"' ~/.docker/config.jsonFix
Remove the saved login for that host. The next pull goes out without a token, which is all a public repository needs.
docker logout public.ecr.aws
docker pull public.ecr.aws/registry_alias/repository_name:image_tagVerify
The pull downloads the layers, and the config file no longer has a public.ecr.aws entry.
grep -c 'public.ecr.aws' ~/.docker/config.jsonConfirmed by docs.aws.amazon.com
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.
ls -l ~/.docker/config.jsonFix
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.
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.awsVerify
docker login reports success and the pull or build that failed now runs to the end.
docker pull public.ecr.aws/registry_alias/repository_name:image_tagConfirmed by docs.aws.amazon.com
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.