ScanSkill

docker login

The command docker login is used to log in to a Docker registry.

Syntax

$ 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 registry

Examples

  • Log in to a self-hosted registry(for eg. localhost: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>
  • Log in using STDIN with a 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:

  • connecting remote daemon(eg. docker-machine provisioned docker engine)
  • user is added to docker group.

To logout from the docker registry:

$ docker logout localhost:8000