docker login
Description | Log in to a registry |
---|---|
Usage |
docker login [OPTIONS] [SERVER]
|
Description
Log in to a registry.
Options
Option | Default | Description |
---|---|---|
-p, --password
|
Password | |
--password-stdin
|
Take the password from stdin | |
-u, --username
|
Username |
Examples
Login to a self-hosted registry
If you want to log in to a self-hosted registry you can specify this by adding the server name.
$ docker login localhost:8080
Provide a password using STDIN (--password-stdin)
To run the
docker login
command non-interactively, you can set the
--password-stdin
flag to provide a password through
STDIN
. Using
STDIN
prevents the password from ending up in the shell's history,
or log-files.
The following example reads a password from a file, and passes it to the
docker login
command using
STDIN
:
$ cat ~/my_password.txt | docker login --username foo --password-stdin
Privileged user requirement
docker login
requires you to use
sudo
or be
root
, except when:
-
Connecting to a remote daemon, such as a
docker-machine
provisioneddocker engine
. -
The user is added to the
docker
group. This will impact the security of your system; thedocker
group isroot
equivalent. See Docker Daemon Attack Surface for details.
You can log in to any public or private repository for which you have
credentials. When you log in, the command stores credentials in
$HOME/.docker/config.json
on Linux or
%USERPROFILE%/.docker/config.json
on
Windows, via the procedure described below.
Credential stores
The Docker Engine can keep user credentials in an external credential store, such as the native keychain of the operating system. Using an external store is more secure than storing credentials in the Docker configuration file.
To use a credential store, you need an external helper program to interact
with a specific keychain or external store. Docker requires the helper
program to be in the client's host
$PATH
.
You can download the helpers from the
docker-credential-helpers
releases page
.
Helpers are available for the following credential stores:
- D-Bus Secret Service
- Apple macOS keychain
- Microsoft Windows Credential Manager
- pass
Configure the credential store
You need to specify the credential store in
$HOME/.docker/config.json
to tell the Docker Engine to use it. The value of the config property should be
the suffix of the program to use (i.e. everything after
docker-credential-
).
For example, to use
docker-credential-osxkeychain
: