2015-06-21 20:41:38 +00:00
<!-- [metadata]>
+++
title = "login"
description = "The login command description and usage"
keywords = ["registry, login, image"]
[menu.main]
parent = "smn_cli"
+++
<![end-metadata]-->
# login
2016-07-07 18:43:18 +00:00
```markdown
Usage: docker login [OPTIONS] [SERVER]
2015-06-21 20:41:38 +00:00
2016-07-07 18:43:18 +00:00
Log in to a Docker registry.
If no server is specified, the default is defined by the daemon.
2015-06-21 20:41:38 +00:00
2016-07-07 18:43:18 +00:00
Options:
--help Print usage
-p, --password string Password
-u, --username string Username
```
2015-06-21 20:41:38 +00:00
If you want to login to a self-hosted registry you can specify this by
adding the server name.
example:
$ docker login localhost:8080
2015-11-02 22:20:38 +00:00
2016-03-01 01:51:36 +00:00
`docker login` requires user to use `sudo` or be `root` , except when:
2015-11-02 22:20:38 +00:00
1. connecting to a remote daemon, such as a `docker-machine` provisioned `docker engine` .
2016-03-01 01:51:36 +00:00
2. user is added to the `docker` group. This will impact the security of your system; the `docker` group is `root` equivalent. See [Docker Daemon Attack Surface ](https://docs.docker.com/security/security/#docker-daemon-attack-surface ) for details.
2015-11-02 22:20:38 +00:00
You can log into any public or private repository for which you have
credentials. When you log in, the command stores encoded credentials in
`$HOME/.docker/config.json` on Linux or `%USERPROFILE%/.docker/config.json` on Windows.
2016-02-08 00:55:17 +00:00
## Credentials store
The Docker Engine can keep user credentials in an external credentials 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 credentials 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` .
This is the list of currently available credentials helpers and where
you can download them from:
2016-03-05 14:38:50 +00:00
- D-Bus Secret Service: https://github.com/docker/docker-credential-helpers/releases
2016-02-08 00:55:17 +00:00
- Apple OS X keychain: https://github.com/docker/docker-credential-helpers/releases
- Microsoft Windows Credential Manager: https://github.com/docker/docker-credential-helpers/releases
### Usage
2016-03-12 13:11:01 +00:00
You need to speficy the credentials store in `$HOME/.docker/config.json`
2016-02-08 00:55:17 +00:00
to tell the docker engine to use it:
```json
{
"credsStore": "osxkeychain"
}
```
If you are currently logged in, run `docker logout` to remove
the credentials from the file and run `docker login` again.
### Protocol
Credential helpers can be any program or script that follows a very simple protocol.
This protocol is heavily inspired by Git, but it differs in the information shared.
The helpers always use the first argument in the command to identify the action.
There are only three possible values for that argument: `store` , `get` , and `erase` .
The `store` command takes a JSON payload from the standard input. That payload carries
2016-03-04 20:00:18 +00:00
the server address, to identify the credential, the user name, and either a password
or an identity token.
2016-02-08 00:55:17 +00:00
```json
{
"ServerURL": "https://index.docker.io/v1",
"Username": "david",
2016-03-04 20:00:18 +00:00
"Secret": "passw0rd1"
2016-02-08 00:55:17 +00:00
}
```
2016-03-04 20:00:18 +00:00
If the secret being stored is an identity token, the Username should be set to
`<token>` .
2016-02-08 00:55:17 +00:00
The `store` command can write error messages to `STDOUT` that the docker engine
will show if there was an issue.
The `get` command takes a string payload from the standard input. That payload carries
the server address that the docker engine needs credentials for. This is
an example of that payload: `https://index.docker.io/v1` .
The `get` command writes a JSON payload to `STDOUT` . Docker reads the user name
and password from this payload:
```json
{
"Username": "david",
2016-03-04 20:00:18 +00:00
"Secret": "passw0rd1"
2016-02-08 00:55:17 +00:00
}
```
The `erase` command takes a string payload from `STDIN` . That payload carries
the server address that the docker engine wants to remove credentials for. This is
an example of that payload: `https://index.docker.io/v1` .
The `erase` command can write error messages to `STDOUT` that the docker engine
will show if there was an issue.