Skip to content
Latchkey

docker/login-action: Authenticate to a Registry

login-action authenticates Docker to a registry so later steps can push images.

Use it before build-push-action when you push. It supports Docker Hub, GHCR, ECR, GCR, and any registry with username/password or token auth.

Key inputs (with:)

  • registry: registry host, e.g. ghcr.io (omit for Docker Hub).
  • username: registry username or actor.
  • password: token or password (use a secret).
  • logout: log out at job end (default true).

Example workflow

.github/workflows/ci.yml
jobs:
  push:
    runs-on: ubuntu-latest
    permissions:
      packages: write
    steps:
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

On any runner

login-action runs on any runner. Latchkey managed runners run it unchanged.

Key takeaways

  • For GHCR, use github.actor and GITHUB_TOKEN with packages: write.
  • Always pass the password from a secret, never inline.
  • Run it before build-push-action when pushing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →