How to fix the "Cannot autolaunch D-Bus without X11 $DISPLAY" error

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.

Note: you must have IAM permissions to use AWS ECR.

You can then provide the password to the Docker CLI login. The password will be valid for 12 hours.

Note: get-login-password is only supported by AWS CLI version 2 or in v1.17.10 or later.

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. This is 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 command 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, if you still get the "Cannot autolaunch D-Bus without X11 $DISPLAY" -

You can try to install the Amazon ECR Docker Credential Helper. What is this exactly? Well, it is a helper for the Docker daemon that makes it easier to use Amazon ECR. Click here to read more about it.

As a last resort, use the “password” option instead of “password-stdin”. Avoid this if possible!

Wrapping up

Hopefully, this helped you solve the “Cannot autolaunch D-Bus without 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.

Why not visit our guides page to see more relevant content?

You may also be interested in

Updates:

  • 2021-07-27 - Added additional info to setup pass


About the Authors

Anto's editorial team loves the cloud as much as you! Each member of Anto's editorial team is a Cloud expert in their own right. Anto Online takes great pride in helping fellow Cloud enthusiasts. Let us know if you have an excellent idea for the next topic! Contact Anto Online if you want to contribute.

Support the Cause

Support Anto Online and buy us a coffee. Anything is possible with coffee and code.

Buy me a coffee



7 Comments on “How to fix the "Cannot autolaunch D-Bus without X11 $DISPLAY" error”

Leave a Reply

Your email address will not be published. Required fields are marked *