From 3e392505a860eb6f99b303932038ccdcdd8951c1 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Thu, 13 Jul 2017 09:03:52 -0600 Subject: [PATCH 1/4] docs: add --password-stdin also add an example of usage Signed-off-by: Tycho Andersen --- docs/reference/commandline/login.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/reference/commandline/login.md b/docs/reference/commandline/login.md index 0b8e697281..df3c5e8ea9 100644 --- a/docs/reference/commandline/login.md +++ b/docs/reference/commandline/login.md @@ -22,9 +22,10 @@ Log in to a Docker registry. If no server is specified, the default is defined by the daemon. Options: - --help Print usage - -p, --password string Password - -u, --username string Username + --help Print usage + -p, --password string Password + --password-stdin Read password from stdin + -u, --username string Username ``` ## Description @@ -40,6 +41,20 @@ adding the server name. $ docker login localhost:8080 ``` +### Provide a password using STDIN + +To run the `docker login` command non-interactively, you can set the +`--password-stdin` flag to provide a password through `STDIN`. Using +`STDIN` prevents the password from ending up in the shell's history, +or log-files. + +The following example reads a password from a file, and passes it to the +`docker login` command using `STDIN`: + +```bash +$ cat ~/my_password.txt | docker login --username foo --password-stdin +``` + ### Privileged user requirement `docker login` requires user to use `sudo` or be `root`, except when: From bbfe23f9e6175e08c7a42b42919611cb038fcc72 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Thu, 13 Jul 2017 09:05:04 -0600 Subject: [PATCH 2/4] bash completion: add --password-stdin Signed-off-by: Tycho Andersen --- contrib/completion/bash/docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 95cc588ca0..e9d8b6f2b6 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -2684,7 +2684,7 @@ _docker_login() { case "$cur" in -*) - COMPREPLY=( $( compgen -W "--help --password -p --username -u" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "--help --password --password-stdin -p --username -u" -- "$cur" ) ) ;; esac } From 90619e5054d3e82a75b1c3768d5de556289c39d9 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Thu, 13 Jul 2017 09:05:18 -0600 Subject: [PATCH 3/4] zsh completion: add --password-stdin Signed-off-by: Tycho Andersen --- contrib/completion/zsh/_docker | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 4b0c1e25c7..075e87aa93 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -2761,6 +2761,7 @@ __docker_subcommand() { _arguments $(__docker_arguments) -A '-*' \ $opts_help \ "($help -p --password)"{-p=,--password=}"[Password]:password: " \ + "($help)--password-stdin[Read password from stdin]" \ "($help -u --user)"{-u=,--user=}"[Username]:username: " \ "($help -)1:server: " && ret=0 ;; From 3b7b6b5f7f46d582f929d3198eefebbe0c36d2eb Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Thu, 13 Jul 2017 09:07:38 -0600 Subject: [PATCH 4/4] fish completion: add --password-stdin Signed-off-by: Tycho Andersen --- contrib/completion/fish/docker.fish | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/completion/fish/docker.fish b/contrib/completion/fish/docker.fish index 38957b8b77..d825922776 100644 --- a/contrib/completion/fish/docker.fish +++ b/contrib/completion/fish/docker.fish @@ -229,6 +229,7 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from load' -s i -l input -d complete -c docker -f -n '__fish_docker_no_subcommand' -a login -d 'Log in to a Docker registry server' complete -c docker -A -f -n '__fish_seen_subcommand_from login' -l help -d 'Print usage' complete -c docker -A -f -n '__fish_seen_subcommand_from login' -s p -l password -d 'Password' +complete -c docker -A -f -n '__fish_seen_subcommand_from login' -l password-stdin -d 'Read password from stdin' complete -c docker -A -f -n '__fish_seen_subcommand_from login' -s u -l username -d 'Username' # logout