docker-login
Authenticate with a Docker registry
TLDR
Interactively log into a registry
Log into a registry with a specific username (user will be prompted for a password)
Log into a registry with username and password
Log into a registry with password from stdin
SYNOPSIS
docker login [OPTIONS] [SERVER]
PARAMETERS
-u, --username string
Username for login
--password string
Password (visible in process list, avoid)
-p, --password-stdin
Read password from STDIN
--password-stdin-force
Force password from STDIN, ignore helpers
--unencrypted-storage
DEPRECATED: Store creds unencrypted
DESCRIPTION
The docker login command authenticates a user to a Docker registry, such as Docker Hub or a private registry. It stores credentials securely in ~/.docker/config.json, often using credential helpers like pass or OS keychain for encryption.
Without arguments, it logs into Docker Hub (registry-1.docker.io). Specify a SERVER for custom registries. The command prompts for username and password interactively, but options allow automation.
Successful login enables docker push, docker pull from private repos. Credentials persist until docker logout. Use --password-stdin in scripts to avoid exposing passwords in process lists or history.
Supports multi-factor auth and various auth backends. Errors occur for invalid creds, network issues, or unsupported registries.
CAVEATS
Never use --password in scripts; visible via ps. Prefer --password-stdin. Some registries require 2FA setup. Fails if credential helper misconfigured.
SERVER
Optional registry URL, e.g., registry.example.com. Defaults to Docker Hub.
EXAMPLES
docker login
docker login localhost:5000 -u user
echo 'pass' | docker login -u user --password-stdin myreg.com
HISTORY
Introduced in Docker 1.0 (2014). Credential store support added in 1.11 (2016). --password-stdin in 17.07 for security. Ongoing updates for auth helpers.
SEE ALSO
docker logout(1), docker push(1), docker pull(1), docker manifest(1)


