docker login

Signs the Docker CLI in to a registry so you can push, or pull private images.

In more detail

Use an access token rather than your password, and --password-stdin so it does not appear in shell history. Credentials are stored in a credential helper or in ~/.docker/config.json, which should be protected like any other secret. In pipelines prefer short-lived tokens.

Example

echo "$REGISTRY_TOKEN" | docker login registry.example.com -u ci-bot --password-stdin

Related terms

Taught in

References