github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/docs/reference/commandline/login.md (about) 1 --- 2 title: "login" 3 description: "The login command description and usage" 4 keywords: "registry, login, image" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # login 17 18 ```markdown 19 Usage: docker login [OPTIONS] [SERVER] 20 21 Log in to a Docker registry. 22 If no server is specified, the default is defined by the daemon. 23 24 Options: 25 --help Print usage 26 -p, --password string Password 27 -u, --username string Username 28 ``` 29 30 ## Description 31 32 Login to a registry. 33 34 ### Login to a self-hosted registry 35 36 If you want to login to a self-hosted registry you can specify this by 37 adding the server name. 38 39 ```bash 40 $ docker login localhost:8080 41 ``` 42 43 ### Privileged user requirement 44 45 `docker login` requires user to use `sudo` or be `root`, except when: 46 47 1. connecting to a remote daemon, such as a `docker-machine` provisioned `docker engine`. 48 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. 49 50 You can log into any public or private repository for which you have 51 credentials. When you log in, the command stores encoded credentials in 52 `$HOME/.docker/config.json` on Linux or `%USERPROFILE%/.docker/config.json` on Windows. 53 54 ### Credentials store 55 56 The Docker Engine can keep user credentials in an external credentials store, 57 such as the native keychain of the operating system. Using an external store 58 is more secure than storing credentials in the Docker configuration file. 59 60 To use a credentials store, you need an external helper program to interact 61 with a specific keychain or external store. Docker requires the helper 62 program to be in the client's host `$PATH`. 63 64 This is the list of currently available credentials helpers and where 65 you can download them from: 66 67 - D-Bus Secret Service: https://github.com/docker/docker-credential-helpers/releases 68 - Apple macOS keychain: https://github.com/docker/docker-credential-helpers/releases 69 - Microsoft Windows Credential Manager: https://github.com/docker/docker-credential-helpers/releases 70 71 You need to specify the credentials store in `$HOME/.docker/config.json` 72 to tell the docker engine to use it. The value of the config property should be 73 the suffix of the program to use (i.e. everything after `docker-credential-`). 74 For example, to use `docker-credential-osxkeychain`: 75 76 ```json 77 { 78 "credsStore": "osxkeychain" 79 } 80 ``` 81 82 If you are currently logged in, run `docker logout` to remove 83 the credentials from the file and run `docker login` again. 84 85 ### Credential helper protocol 86 87 Credential helpers can be any program or script that follows a very simple protocol. 88 This protocol is heavily inspired by Git, but it differs in the information shared. 89 90 The helpers always use the first argument in the command to identify the action. 91 There are only three possible values for that argument: `store`, `get`, and `erase`. 92 93 The `store` command takes a JSON payload from the standard input. That payload carries 94 the server address, to identify the credential, the user name, and either a password 95 or an identity token. 96 97 ```json 98 { 99 "ServerURL": "https://index.docker.io/v1", 100 "Username": "david", 101 "Secret": "passw0rd1" 102 } 103 ``` 104 105 If the secret being stored is an identity token, the Username should be set to 106 `<token>`. 107 108 The `store` command can write error messages to `STDOUT` that the docker engine 109 will show if there was an issue. 110 111 The `get` command takes a string payload from the standard input. That payload carries 112 the server address that the docker engine needs credentials for. This is 113 an example of that payload: `https://index.docker.io/v1`. 114 115 The `get` command writes a JSON payload to `STDOUT`. Docker reads the user name 116 and password from this payload: 117 118 ```json 119 { 120 "Username": "david", 121 "Secret": "passw0rd1" 122 } 123 ``` 124 125 The `erase` command takes a string payload from `STDIN`. That payload carries 126 the server address that the docker engine wants to remove credentials for. This is 127 an example of that payload: `https://index.docker.io/v1`. 128 129 The `erase` command can write error messages to `STDOUT` that the docker engine 130 will show if there was an issue. 131 132 ### Credential helpers 133 134 Credential helpers are similar to the credential store above, but act as the 135 designated programs to handle credentials for *specific registries*. The default 136 credential store (`credsStore` or the config file itself) will not be used for 137 operations concerning credentials of the specified registries. 138 139 ### Logging out 140 141 If you are currently logged in, run `docker logout` to remove 142 the credentials from the default store. 143 144 Credential helpers are specified in a similar way to `credsStore`, but 145 allow for multiple helpers to be configured at a time. Keys specify the 146 registry domain, and values specify the suffix of the program to use 147 (i.e. everything after `docker-credential-`). 148 For example: 149 150 ```json 151 { 152 "credHelpers": { 153 "registry.example.com": "registryhelper", 154 "awesomereg.example.org": "hip-star", 155 "unicorn.example.io": "vcbait" 156 } 157 } 158 ```