docker/login-action@v4

GitHub Action to login against a Docker registry

At a glance

Latest major
v4
Repository
docker/login-action
Inputs
7 (0 required)
Outputs
0
Runs using
node24
License
Apache-2.0
Last checked

Inputs and outputs come straight from the action's official action.yml. See our editorial standards.

Usage

- uses: docker/login-action@v4

Inputs

NameRequiredDefaultDescription
registryNononeServer address of Docker registry. If not set then will default to Docker Hub
usernameNononeUsername used to log against the Docker registry
passwordNononePassword or personal access token used to log against the Docker registry
ecrNononeSpecifies whether the given registry is ECR (auto, true or false)
scopeNononeScope for the authentication token
logoutNotrueLog out from the Docker registry at the end of a job
registry-authNononeRaw authentication to registries, defined as YAML objects

Outputs

This action declares no outputs in its action.yml.

Examples

Log in to GitHub Container Registry

Use the built-in token, so there is no secret to create.

name: Example
on:
  push:
    branches: [main]

permissions:
  contents: read
  packages: write

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - name: Docker Login
        uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

Log in to Docker Hub

Use an access token stored as a repository secret, not your account password.

name: Example
on:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - name: Docker Login
        uses: docker/login-action@v4
        with:
          username: ${{ vars.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

Each example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.

Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.