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.
github-actions
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.
.github/workflows/ci.yml
- 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.
Related guides
GitHub Actions docker/build-push-action "denied" on pushFix docker/build-push-action "ERROR: denied" - buildx could not push the image because the registry rejected…
GitHub Actions docker/setup-buildx-action "failed to initialize builder"Fix docker/setup-buildx-action "failed to initialize builder" - buildx could not create the builder instance,…
GitHub Actions slackapi/slack-github-action "invalid_auth"Fix slackapi/slack-github-action "invalid_auth" - the bot token is missing, malformed, or lacks the scope for…