LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

docker-login

authenticate with Docker registries

TLDR

Log in to Docker Hub using device code flow
$ docker login
copy
Log in to Docker Hub with a username (prompts for password)
$ docker login -u [username]
copy
Log in to a specific registry
$ docker login [registry.example.com]
copy
Log in non-interactively using stdin for the password
$ echo [token] | docker login -u [username] --password-stdin
copy
Log in to GitHub Container Registry
$ echo [PAT] | docker login ghcr.io -u [username] --password-stdin
copy

SYNOPSIS

docker login [options] [server]

DESCRIPTION

docker login authenticates with a Docker registry. When no server is specified, it authenticates to Docker Hub using a device code flow by default, unless --username is provided. Credentials are stored in ~/.docker/config.json or in an external credential store (such as the OS native keychain) when configured. Authentication is required to push images and access private repositories.

PARAMETERS

-u, --username string

Username.
-p, --password string
Password or Personal Access Token (insecure, prefer --password-stdin).
--password-stdin
Take password from stdin.

CONFIGURATION

~/.docker/config.json

Stores registry credentials and authentication tokens. Uses credential helpers for secure storage when available.

CAVEATS

Using -p exposes the password in shell history and log files. Always prefer --password-stdin for scripted logins.

SEE ALSO

Copied to clipboard
Kai