← Back to all fixes

docker push fails with authentication required in CI

The Issue

CI step `docker push myregistry/myapp:v1` fails: `unauthorized: authentication required`

Root Cause

The CI runner is not logged into the registry. Credentials either not set or incorrectly referenced.

How to Fix
  1. Add a login step before push: `docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY`
  2. Store credentials as CI secrets, not hardcoded in the YAML
  3. For ECR (AWS): use `aws ecr get-login-password | docker login --username AWS --password-stdin <registry>`
  4. For GCR: use `gcloud auth configure-docker` or a service account key
  5. Verify the secret names match what your YAML references exactly (case-sensitive)