GitHub Actions docker/login-action "Username and password required"
docker/login-action needs both a username and a password (or token). When a referenced secret is empty or misnamed, the action receives a blank value and refuses to attempt the login.
What this error means
A docker/login-action step fails immediately stating that a username and password are required, before contacting the registry.
Error: Username and password requiredCommon causes
Secret unset or misnamed
A password mapped to a secret that does not exist resolves to an empty string, which the action rejects.
Secret not available to the context
Secrets are not passed to workflows triggered by forked pull_request events, so the value is empty there.
How to fix it
Supply non-empty credentials
- Confirm the secret name matches exactly and the secret has a value.
- For GHCR, use github.actor and secrets.GITHUB_TOKEN.
- Skip or gate the login on forked PRs where secrets are unavailable.
- uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}How to prevent it
- Double-check secret names against repository/organization settings.
- Guard registry login steps so forked PRs without secrets do not run them.