docker login prints a warning about --password and how to log in without it
WARNING! Using --password via the CLI is insecure. Use --password-stdin.Short answer
Docker prints this warning whenever you give docker login a real value with --password or -p, because the secret then sits in shell history and process lists. Pipe the secret into docker login with --username and --password-stdin instead. The login still works either way; the warning is only a nudge.
Fix it fast
1Find out which cause you have
Find where the password is passed as an argument. In a shell, search your history; in CI, search the pipeline files for the flag.
grep -rn -E 'docker login.*(--password|-p )' . --include='*.yml' --include='*.yaml' --include='*.sh'2Match what you see, then jump to its fix
- 1
WARNING! Using --password via the CLI is insecure. Use --password-stdin.The secret is passed as an argument with --password or -pFix - 2
the --password-stdin option requires --username to be set--password-stdin is used without --usernameFix - 3
conflicting options: cannot specify both --password and --password-stdin--password and --password-stdin are both on the same commandFix - 4
Docker stores the credential in ~/.docker/config.json after a successful loginThe login works, but the credential is stored as base64 in config.jsonFix
- 1
What does the error look like?
WARNING! Using --password via the CLI is insecure. Use --password-stdin.conflicting options: cannot specify both --password and --password-stdinthe --password-stdin option requires --username to be set
Cause 1 of 4
The secret is passed as an argument with --password or -p
1Check
Look for docker login commands that carry the secret after --password or -p. The CLI prints the warning whenever that value is not empty and is not a single dash.
grep -rn 'docker login' . | grep -E -- '--password |-p '2Fix
Send the secret on standard input and tell Docker to read it there. In CI, read it from a masked variable, never type it inline.
echo "$REGISTRY_TOKEN" | docker login --username my-user --password-stdin
# or from a file that only you can read
cat ~/my_password.txt | docker login --username my-user --password-stdin3Verify
The command prints Login Succeeded and no warning line.
echo "$REGISTRY_TOKEN" | docker login --username my-user --password-stdinConfirmed by docs.docker.com
Cause 2 of 4
--password-stdin is used without --username
1Check
Reading the secret from stdin only replaces the password. The CLI still needs the user name, and an empty value fails too.
echo "username is [$REGISTRY_USER]"2Fix
Pass --username with a non-empty value. In CI, make sure the user variable is defined for that job.
echo "$REGISTRY_TOKEN" | docker login --username "$REGISTRY_USER" --password-stdin3Verify
The login succeeds with no usage error.
echo "$REGISTRY_TOKEN" | docker login --username "$REGISTRY_USER" --password-stdinConfirmed by raw.githubusercontent.com
Cause 3 of 4
--password and --password-stdin are both on the same command
1Check
A script was half converted: the new flag was added but the old --password argument was left in place.
grep -rn -- '--password-stdin' . | grep -E -- '--password [^-]|-p '2Fix
Delete the old --password value. The only form that may stay next to stdin is a single dash, which also means read from stdin.
echo "$REGISTRY_TOKEN" | docker login --username my-user --password-stdin3Verify
The command runs without the conflicting options error.
echo "$REGISTRY_TOKEN" | docker login --username my-user --password-stdinConfirmed by raw.githubusercontent.com
Cause 4 of 4
The login works, but the credential is stored as base64 in config.json
1Check
Without a credential store, Docker keeps the login in config.json in base64, which is not encryption.
cat ~/.docker/config.json2Fix
Configure an external credential store through the credsStore key, then log in again. Docker says an external store is more secure than the config file.
# ~/.docker/config.json (use the helper installed on your OS)
{
"credsStore": "osxkeychain"
}3Verify
After logging in again, the auths entry no longer holds an encoded secret.
cat ~/.docker/config.jsonConfirmed by docs.docker.com
How do I stop it coming back?
- Use --password-stdin in every script and pipeline from the start.
- Give CI a registry token or personal access token with only the scope it needs, not a user password.
- Keep the secret in the CI secret store and let the runner mask it in logs.
- Use a credential store on developer machines.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix