github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/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/cli GitHub
     8       repository at https://github.com/docker/cli/. 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        --password-stdin          Read password from stdin
    28    -u, --username       string   Username
    29  ```
    30  
    31  ## Description
    32  
    33  Login to a registry.
    34  
    35  ### Login to a self-hosted registry
    36  
    37  If you want to login to a self-hosted registry you can specify this by
    38  adding the server name.
    39  
    40  ```bash
    41  $ docker login localhost:8080
    42  ```
    43  
    44  ### Provide a password using STDIN
    45  
    46  To run the `docker login` command non-interactively, you can set the
    47  `--password-stdin` flag to provide a password through `STDIN`. Using
    48  `STDIN` prevents the password from ending up in the shell's history,
    49  or log-files.
    50  
    51  The following example reads a password from a file, and passes it to the
    52  `docker login` command using `STDIN`:
    53  
    54  ```bash
    55  $ cat ~/my_password.txt | docker login --username foo --password-stdin
    56  ```
    57  
    58  ### Privileged user requirement
    59  
    60  `docker login` requires user to use `sudo` or be `root`, except when:
    61  
    62  1.  connecting to a remote daemon, such as a `docker-machine` provisioned `docker engine`.
    63  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/engine/security/security/#docker-daemon-attack-surface) for details.
    64  
    65  You can log into any public or private repository for which you have
    66  credentials.  When you log in, the command stores credentials in
    67  `$HOME/.docker/config.json` on Linux or `%USERPROFILE%/.docker/config.json` on
    68  Windows, via the procedure described below.
    69  
    70  ### Credentials store
    71  
    72  The Docker Engine can keep user credentials in an external credentials store,
    73  such as the native keychain of the operating system. Using an external store
    74  is more secure than storing credentials in the Docker configuration file.
    75  
    76  To use a credentials store, you need an external helper program to interact
    77  with a specific keychain or external store. Docker requires the helper
    78  program to be in the client's host `$PATH`.
    79  
    80  This is the list of currently available credentials helpers and where
    81  you can download them from:
    82  
    83  - D-Bus Secret Service: https://github.com/docker/docker-credential-helpers/releases
    84  - Apple macOS keychain: https://github.com/docker/docker-credential-helpers/releases
    85  - Microsoft Windows Credential Manager: https://github.com/docker/docker-credential-helpers/releases
    86  - [pass](https://www.passwordstore.org/): https://github.com/docker/docker-credential-helpers/releases
    87  
    88  #### Configure the credentials store
    89  
    90  You need to specify the credentials store in `$HOME/.docker/config.json`
    91  to tell the docker engine to use it. The value of the config property should be
    92  the suffix of the program to use (i.e. everything after `docker-credential-`).
    93  For example, to use `docker-credential-osxkeychain`:
    94  
    95  ```json
    96  {
    97  	"credsStore": "osxkeychain"
    98  }
    99  ```
   100  
   101  If you are currently logged in, run `docker logout` to remove
   102  the credentials from the file and run `docker login` again.
   103  
   104  #### Default behavior
   105  
   106  By default, Docker looks for the native binary on each of the platforms, i.e.
   107  "osxkeychain" on macOS, "wincred" on windows, and "pass" on Linux. A special
   108  case is that on Linux, Docker will fall back to the "secretservice" binary if
   109  it cannot find the "pass" binary. If none of these binaries are present, it
   110  stores the credentials (i.e. password) in base64 encoding in the config files
   111  described above.
   112  
   113  #### Credential helper protocol
   114  
   115  Credential helpers can be any program or script that follows a very simple protocol.
   116  This protocol is heavily inspired by Git, but it differs in the information shared.
   117  
   118  The helpers always use the first argument in the command to identify the action.
   119  There are only three possible values for that argument: `store`, `get`, and `erase`.
   120  
   121  The `store` command takes a JSON payload from the standard input. That payload carries
   122  the server address, to identify the credential, the user name, and either a password
   123  or an identity token.
   124  
   125  ```json
   126  {
   127  	"ServerURL": "https://index.docker.io/v1",
   128  	"Username": "david",
   129  	"Secret": "passw0rd1"
   130  }
   131  ```
   132  
   133  If the secret being stored is an identity token, the Username should be set to
   134  `<token>`.
   135  
   136  The `store` command can write error messages to `STDOUT` that the docker engine
   137  will show if there was an issue.
   138  
   139  The `get` command takes a string payload from the standard input. That payload carries
   140  the server address that the docker engine needs credentials for. This is
   141  an example of that payload: `https://index.docker.io/v1`.
   142  
   143  The `get` command writes a JSON payload to `STDOUT`. Docker reads the user name
   144  and password from this payload:
   145  
   146  ```json
   147  {
   148  	"Username": "david",
   149  	"Secret": "passw0rd1"
   150  }
   151  ```
   152  
   153  The `erase` command takes a string payload from `STDIN`. That payload carries
   154  the server address that the docker engine wants to remove credentials for. This is
   155  an example of that payload: `https://index.docker.io/v1`.
   156  
   157  The `erase` command can write error messages to `STDOUT` that the docker engine
   158  will show if there was an issue.
   159  
   160  ### Credential helpers
   161  
   162  Credential helpers are similar to the credential store above, but act as the
   163  designated programs to handle credentials for *specific registries*. The default
   164  credential store (`credsStore` or the config file itself) will not be used for
   165  operations concerning credentials of the specified registries.
   166  
   167  #### Configure credential helpers
   168  
   169  If you are currently logged in, run `docker logout` to remove
   170  the credentials from the default store.
   171  
   172  Credential helpers are specified in a similar way to `credsStore`, but
   173  allow for multiple helpers to be configured at a time. Keys specify the
   174  registry domain, and values specify the suffix of the program to use
   175  (i.e. everything after `docker-credential-`).
   176  For example:
   177  
   178  ```json
   179  {
   180    "credHelpers": {
   181      "registry.example.com": "registryhelper",
   182      "awesomereg.example.org": "hip-star",
   183      "unicorn.example.io": "vcbait"
   184    }
   185  }
   186  ```
   187  
   188  ## Related commands
   189  
   190  * [logout](logout.md)