How to force 'docker login' command to ignore existing credentials helper?
Logging out the current user, before logging in with a different user name worked for me. Logging out removed the saved docker credentials.
docker logout <reponame>
docker login <reponame>
Unfortunately, Docker (as of 18.06) first looks for the docker-credential-*
binaries, and if it finds any of them, it will automatically overwrite the "credsStore"
value in ~/.docker/config.json
.
Your only workaround would be to install docker-credential-pass
in your home directory so that Docker will use that instead of docker-credential-secretservice
. docker-credential-pass
does not require a GUI.
Steps to install docker-credential-pass
:
docker login fails on a server with no X11 installed
To avoid using a credsStore
and to store a plaintext auth token in your docker config (e.g. ~/.docker/config.json
), delete the "credsStore"
key from your docker config file and rerun docker login
.
When you run docker login
, it will give a warning but will save the auth token into the file.
$ docker login
Username: someuser
Password:
WARNING! Your password will be stored unencrypted in ~/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
The resulting docker config file should look like this:
{
"auths": {
"your.docker.registry": {
"auth": "dXNlcm5hbWU6cGFzc3dvcmQK="
}
}
}
The auth
token is simply a base64 encoded string of the form username:password
.
This worked for Docker Engine versions 19 and 20.