Go back ←

Docker Private Registry Login

January 17, 2020

Docker is very valuable tool. It makes life of programmer and system administrator much easier. At least, that’s the way it is supposed to be. Once in a while, good tools have some wierd quirks, and odds are you will bump right into it when you except it least. On early morning, my mailbox was spammed by broken builds. Just a quick peek into the logs and command that has failed is:

docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
> returning:
> error getting credentials - err: exit status 1, out: `Cannot autolaunch D-Bus without X11 $DISPLAY`

Issue is weird because, obviously, credentials are correct. It seems that the error is only showing up on servers. A few google searches later, and you again, realize, you are not that lucky. Someone had that issue before.

Seems like one of the credentials helper depends on x11 and this being a server without graphics windows system, is where it breaks. We will not dwell on it but rather fix it. You can fix it by the solution provided in discussion on the link above, but it includes installing additional software on the server and we sometimes do not want that. I’ve thought of a better use.

Fix

If there exist config.json based in ~/.docker on server with following content:

"auths": {
  "my.registry.com": {
    "auth": "dXNlcm5hbWU6cGFzc3dvcmQK"
  }
},
"credStore": 'secretservice'

Now, proceed to remove the last line containing credStore property. It seems that login is working back again like it is supposed to. Yes it pops up the following:

WARNING! Your password will be stored unencrypted in /home/adwised/.docker/config.json.

However, if we have properly secured registry with appropriate certificate, communication would be secure. So, we are good to use plaintext password in config.file. If you are wondering where it is plain text, remember that

"auth": "dXNlcm5hbWU6cGFzc3dvcmQK"

is just encoded, not encrypted.

If you do not have config file, feel free to use mine and substitute with appropriate values. When on terminal, always remember that you can:

> echo "username:password" | base64
dXNlcm5hbWU6cGFzc3dvcmQK

An easier alternative to the common problem, so that shipment of your containers can go back to the good old ways.

Good luck.

Last edit on 2020-09-18T16:19:37.121Z

© 2018.