Are you using the “aws ecr get-login-password” with the “docker login” command? If so, let’s fix the “Cannot autolaunch D-Bus without X11 $DISPLAY” error.
The error you are getting should look something like this:
Error saving credentials: error storing credentials - err: exit status 1, out: Cannot autolaunch D-Bus without X11 $DISPLAY
What do these commands do?
aws ecr get-login-password – The “get-login-password” command fetches and displays a password that you can use to authenticate against an AWS ECR registry.
You can then provide the password to the Docker CLI login. The password will be valid for 12 hours.
Below is an example of the output:
root@ip-172-26-8-7:~# aws ecr get-login-password --region ap-southeast-2
eyJwYXlsb2FkIjoiNFlRQk1DTGNqNkhaNDF2YWVXTnZ4SndUd0NMS0VvQmE0QVNQQWUyQTVoUWJ
UUnRLK04zRjVHTnFuM1RDd3lleU5zMkZtcVBuMVlWdG1lQTNpa2hYL3IvbCtnci9ZQ0ovekZZYy
t3elhwTmd3N2VrVk5pNHZF
docker login – The “docker login” command enables you to log in to the Docker registry and accepts the following options: –password, –password-stdin, and –username. You use the “username” option to specify the username.
The “password” option allows you to specify a password string. Note, however, that using the “password” option is insecure because the password will be stored in the shell history or log files. The “password-stdin” option provides the password via STDIN and is thus more secure than the “password” option.
Here is an example of the warning you will get if you use the insecure–password option:
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error saving credentials: error storing credentials - err: exit status 1, out: Cannot autolaunch D-Bus without X11 $DISPLAY
How are these commands used together?
The “aws ecr get-login-password” command retrieves a password from AWS and then pipes the output via STDIN to “docker login”.
The expected result is that Docker should say:
Login Succeeded.
And Docker should not say:
Error saving credentials: error storing credentials - err: exit status 1, out: Cannot autolaunch D-Bus without X11 $DISPLAY
What is the cause of the “Cannot autolaunch D-Bus without X11 $DISPLAY” error?
Docker supports a wide variety of credential helpers. These include the: D-Bus Secret Service, Apple macOS keychain, Microsoft Windows Credential Manager, and pass.
As per Docker:
By default, Docker looks for the native binary on each of the platforms; i.e., “osxkeychain” on macOS, “wincred” on windows, and “pass” on Linux. A special case is that on Linux, Docker will fall back to the “secretservice” binary if it cannot find the “pass” binary.
What is the solution
The simplest solution to fix the “Cannot autolaunch D-Bus without X11 $DISPLAY” error is to install pass—the standard UNIX password manager. You do not need to remove docker-compose! However, the pass depends on gpg, so you will need to install two applications.
You can install pass and gpg using the following command:
Ubuntu / Debian
sudo apt-get install pass gnupg2
# create a gpg2 key
gpg2 --gen-key
# create the password store using the gpg user id
pass init $gpg_id
Fedora / RHEL
sudo yum install pass gnupg2
# create a gpg2 key
gpg2 --gen-key
# create the password store using the gpg user id
pass init $gpg_id
Alternatively, suppose you still get the “Cannot autolaunch D-Bus without X11 $DISPLAY”. In that case, you can try to install the Amazon ECR Docker Credential Helper, which is a helper for the Docker daemon that makes it easier to use Amazon ECR. Click here to read more about it.
Use the “password” option instead of “password-stdin” as a last resort. Avoid this if possible!
Wrapping up
Hopefully, this helped you solve the “Cannot autolaunch D-Bus without getting the X11 $DISPLAY” error! Share or like this post if your issue is now fixed. Otherwise, let us know in the comments, and we will update this post.
You may also be interested in
Updates:
- 2021-07-27 – Added additional info to setup pass
Thank you, it worked like a charm!
Nope, it doesn’t work for me
Rancher Docker VM in TrueNAS 12.
Thank you, man!
This is what I really needed.
Nope, doesn’t work for me on Ubuntu.
Sorry to hear Graham. Let me know if you find something that works for you.
on debian 10 I just typed apt-get install pass, It work very ice.
thank bro
I am very glad you got it working! Thanks for the comment.
It works for me just fine! Thank you very much!