GitLab CI Services From Amazon ECR Fail to Pull After 12 Hours: Switch to the ECR Credential Helper
Overview
GitLab CI jobs whose image or services come from a private Amazon ECR registry fail with no basic auth credentials or HTTP 403 when DOCKER_AUTH_CONFIG holds a pasted ECR token, which lasts 12 hours. Refresh it to unblock, then install docker-credential-ecr-login on a self-managed runner with a pull-only IAM role and use credHelpers.
Diagnose
Symptom
What responders observe.
Use it when every job that pulls from 123456789012.dkr.ecr.eu-west-2.amazonaws.com (your account and Region will differ) fails before any script line runs, while jobs using only public images on the same runner pass.
A service written like this fails in the same way as a job image: integration-tests: image: 123456789012.dkr.ecr.eu-west-2.amazonaws.com/build/node:22 services: [{ name: 123456789012.dkr.ecr.eu-west-2.amazonaws.com/test/api-stub:1.4, alias: api }] script: [npm test] AWS lists three known causes of no basic auth credentials or a 403 from ECR after a successful login: a token from another Region, missing repository permission, or an expired token.
Failures that began about 12 hours after the variable was last edited point at the third.
Detection
Metrics, logs and confirmation commands.
Root cause
Why the incident occurred.
Contain and prevent
Blast radius
What else this can affect.
Prevention
Controls and guardrails that stop it recurring.
-
Search every project, group and runner for DOCKER_AUTH_CONFIG values that hold an ECR hostname under "auths" and move each one to credHelpers.
-
A runner-level credential lets any job on that runner pull with the same rights across projects, so restrict which projects use it.
-
Keep the runner's role pull-only, and review it like any workload role: one scoped too tightly fails just as quietly, as a Lambda execution role that only covers /aws/lambda shows.
-
Keep the helper on the instance role rather than a user profile: AWS says the helper does not support MFA, and MFA rules have broken other unattended sign-ins before, such as Amazon Kendra's SharePoint Online sync.
Fix
Pre-flight checks
Check these before you change anything.
-
Administrator access to the self-managed GitLab Runner host and its config.toml.
-
Maintainer access to the CI/CD variables that hold DOCKER_AUTH_CONFIG.
-
Rights to attach an IAM role and policy to the runner instance.
-
AWS CLI on the runner host.
Commands
aws ecr get-authorization-token --region eu-west-2 --output text --query 'authorizationData[].authorizationToken'
aws sts get-caller-identity
aws ecr describe-images --repository-name test/api-stub --image-ids imageTag=1.4
docker-credential-ecr-login
sudo dnf install -y amazon-ecr-credential-helper
sudo apt install amazon-ecr-credential-helper
docker logout 123456789012.dkr.ecr.eu-west-2.amazonaws.com
Verify and recover
Verification
Evidence required before you close the incident.
-
Retry the failed pipeline after switching to credHelpers. — Job passes preparation; no Service probably didn't start properly warning for the ECR service. — The job image and service image pull and the job runs its script.
-
Run the same pipeline more than 12 hours after the switch. — Successful pulls from the ECR registry. — Pulls still succeed after a static token would have expired.
-
Run aws sts get-caller-identity on the runner host. — Arn of the instance role. — The Arn is the intended pull-only role.
Rollback
The safe way back.
-
Restore config.toml and any runner config.json from the backup taken before the change.
-
Set DOCKER_AUTH_CONFIG back to an auths entry holding a freshly generated token from aws ecr get-authorization-token
-
never restore the expired value.
-
The IAM role and helper package can stay
-
nothing calls the helper once no configuration names ecr-login.
Escalate when
Conditions that need another owner.
-
Instance runners, or any runner whose host you cannot change: the team that owns the runners.
-
403 That continues with the helper, the right Region and the expected Arn: the owner of the repository policy, especially when the registry belongs to another account.
-
An organisation rule that requires MFA for this identity: the IAM owner.
-
AWS states the credential helper does not currently support MFA.
-
Repository policy owner.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Sources
Based on the vendor sources listed below. Check each step against your environment before acting.
First published 22 November 2026
Run your CI/CD jobs in Docker containers
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Services
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Private registry authentication in Amazon ECR
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Troubleshooting Docker commands and issues when using Amazon ECR
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Amazon ECR Docker Credential Helper README
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Private repository policy examples in Amazon ECR
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
AWS managed policies for Amazon Elastic Container Registry
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
AWS CLI Command Reference: aws ecr get-authorization-token
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
AWS CLI Command Reference: aws sts get-caller-identity
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
AWS CLI Command Reference: aws ecr describe-images
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Related runbooks
AWS DRS Replication Agent Crash or Agent Not Seen
Diagnose an AWS Elastic Disaster Recovery replication agent crash or AGENT_NOT_SEEN state by checking the source service, agent logs, regional endpoint access and TCP 1500 path before any restart or reinstall that could trigger a rescan and affect RPO.
AWS Step Functions Execution Timeout: Diagnose States.Timeout
Diagnose an AWS Step Functions States.Timeout by separating workflow, task, heartbeat, HTTP Task and downstream-service limits, then change retry, catch or timeout policy only after duplicate side effects and execution type are understood.