Madushan Pathirana
08/20/2025, 10:36 AMMarvin
08/20/2025, 10:36 AMMarvin
08/20/2025, 10:40 AMaws ecr get-login-password --region ap-southeast-1 \
| docker login --username AWS --password-stdin <http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com>
3) Test pull on the worker host:
docker pull <http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:2025-08-19t04-28-44-524659-00-00|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com/credilinq-prefect:2025-08-19t04-28-44-524659-00-00>
If that works, your next Prefect run should, too… at least until the token expires. Use a cron/systemd timer to refresh, or use the credential helper below.
Option B: Amazon ECR Docker credential helper (recommended)
1) Install the helper on the worker host: https://github.com/awslabs/amazon-ecr-credential-helper
2) Configure Docker to use it for your registry (no manual login needed):
cat ~/.docker/config.json
{
"credHelpers": {
"<http://010614160260.dkr.ecr.ap-southeast-1.amazonaws.com|010614160260.dkr.ecr.ap-southeast-1.amazonaws.com>": "ecr-login"
}
}
3) Ensure the worker process has AWS creds it can use (instance role, or env vars). If you run the worker via systemd, set environment:
# /etc/systemd/system/prefect-worker.service.d/override.conf
[Service]
Environment="AWS_REGION=ap-southeast-1"
# Or provide keys (prefer roles over static keys)
# Environment="AWS_ACCESS_KEY_ID=..."
# Environment="AWS_SECRET_ACCESS_KEY=..."
# Environment="AWS_SESSION_TOKEN=..."
Then systemctl daemon-reload && systemctl restart prefect-worker
.
Sanity checks
- Does the tag actually exist?
aws ecr describe-images \
--region ap-southeast-1 \
--repository-name credilinq-prefect \
--image-ids imageTag=2025-08-19t04-28-44-524659-00-00
- Can Docker pull it manually (outside Prefect)? If not, Prefect won’t either.
Prefect-specific knobs (3.x)
- Prefect doesn’t pass registry credentials to Docker; it relies on the Docker engine’s auth on the worker host.
- To reduce pull chatter once the image is present, set your Docker work pool’s default values to use image_pull_policy
“IfNotPresent” in the UI. That won’t fix auth, but it avoids re-pulling on every run once the image is there.
- Ensure your deployment points to the exact image:tag you pushed to ECR.
Useful docs
- AWS ECR auth overview: https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html
- Docker login via AWS CLI: https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html#registry-auth-token
- Amazon ECR credential helper: https://github.com/awslabs/amazon-ecr-credential-helper
- Prefect workers and work pools: https://docs.prefect.io/latest/concepts/work-pools-and-workers/
- Prefect Docker integration docs: https://prefecthq.github.io/prefect-docker/#docker-worker
If you tell me how your worker is running (systemd, container, VM with instance profile, etc.), I can give the exact steps for that setup. I promise only a minimal amount of existential dread.