The command docker login
is used to log in to a Docker registry.
$ docker login [OPTIONS] [SERVER]
Here, SERVER can be either docker registry or any other self-hosted
registry URL.
Options:
--password
, -p
→ Password for registry--password-stdin
→ Take the password from STDIN--username
, -u
→ Username for registrylocalhost:8000
)$ docker login localhost:8000
Username: cloudyfox
Password:
It will prompt for credentials.
OR, you can log in through the command straight:
# Using username and password
$ docker login localhost:8000 -u <username> -p <password>
Also, you can run docker login
command non-interactively. For this, you set --password-stdin
flag to provide a password through STDIN
.
$ cat /path/to/my_password.txt | docker login --username cloudyfox --password-stdin
In the above command, a password file is read and passed to the docker login
command using STDIN
.
Note: docker login
requires sudo
or root
access when:
docker-machine
provisioned docker engine
)docker
group. To logout from the docker registry:
$ docker logout localhost:8000