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 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.

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 Anto Online

Anto, a seasoned technologist with over two decades of experience, has traversed the tech landscape from Desktop Support Engineer to enterprise application consultant, specializing in AWS serverless technologies. He guides clients in leveraging serverless solutions while passionately exploring cutting-edge cloud concepts beyond his daily work. Anto's dedication to continuous learning, experimentation, and collaboration makes him a true inspiration, igniting others' interest in the transformative power of cloud computing.

View all posts by Anto Online

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

  1. on debian 10 I just typed apt-get install pass, It work very ice.
    thank bro

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.