添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to deploy a docker configuration with images on a private docker registry.

Now, every time I execute docker login registry.example.com , I get the following error message:

error getting credentials - err: exit status 1, out: Cannot autolaunch D-Bus without X11 $DISPLAY

The only solution I found for non-MacOS users was to run export $(dbus-launch) first, but that did not change anything.

I am running Ubuntu Server and tried with both the Ubuntu Docker package and the Docker-CE package.

How can I log in without an X11 session?

Remove your docker-compose and it should work. It seems like a bug: github.com/docker/compose/issues/6023 lvthillo Jul 7, 2018 at 12:22

Looks like this is because it defaults to use the secretservice executable which seems to have some sort of X11 dependency for some reason. If you install and configure pass docker will use that instead which seems to solve the problem.

In a nutshell (from https://github.com/docker/compose/issues/6023 )

sudo apt install gnupg2 pass 
gpg2 --full-generate-key

This generates a you a gpg2 key. After that's done you can list it with

gpg2 -k

Copy the key id (from the line labelled [uid]) and do

pass init "whatever key id you have"

Now docker login should work.

There are a couple of bugs logged on launchpad regarding this:

https://bugs.launchpad.net/ubuntu/+source/golang-github-docker-docker-credential-helpers/+bug/1794307

https://bugs.launchpad.net/ubuntu/+source/docker-compose/+bug/1796119

Thanks for the answer. I switched to debian where things work just like they do on my arch dev machine so unfortunately I cannot test your solution – msrd0 Sep 10, 2018 at 7:30 this solution gave me WARNING! Your password will be stored unencrypted in /home/adwised/.docker/config.json. on ubuntu18.04 – Phoenix Dec 13, 2019 at 16:24 @MohammadMasoumi then pass wasn't installed properly or your docker install can't find it for some reason – ChrisWue Dec 16, 2019 at 23:58 For me (ubuntu 18.04) the instruction "from the line labelled [uid]" was incorrect, instead needed to look for the ID in the entry labelled pub. (But answer still helpful, this is just an FYI in case others using it encounter the same) – Daryn Mar 19, 2020 at 10:40 like @Neo I got "Warning! ... json;" (on debian 10.5) but followed by this advice to fix it : Configure a credential helper to remove this warning. See docs.docker.com/engine/reference/commandline/login/… – herve-guerin Nov 21, 2020 at 0:10 This works, and allows you to login, but your password will be stored unencrypted. Docker gives this notice: WARNING! Your password will be stored unencrypted in $HOME/.docker/config.json. – Azeirah May 11, 2019 at 21:18 This docker login failure is apparently a known issue which is attributed to the golang-docker-credential-helpers Ubuntu package. This answer does work to allow you to docker login without a GUI, but as @tmuecksch mentioned, afterwards you will have to reinstall docker-compose (and the golang... package, if you want it). As mentinoed by @Azeirah, I did get a warning stating my password will be stored unencrypted in ..., but it was not actually stored anywhere that I could find. – travisw Oct 30, 2019 at 13:40 The real question is, how to get the old behaviour (storing unencrypted in xyz) without uninstalling anything. – Marandil Nov 11, 2020 at 16:00

You can remove the offending package golang-docker-credential-helpers without removing all of docker-compose.

The following worked for me on a server without X11 installed:

dpkg -r --ignore-depends=golang-docker-credential-helpers golang-docker-credential-helpers

and then

echo 'foo' | docker login mydockerrepo.com -u dockeruser --password-stdin

Source:

bug reported in debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=910823#39
bug reported on ubuntu: https://bugs.launchpad.net/ubuntu/+source/docker-compose/+bug/1796119

That work for me, but is there a risk that the package gets reinstalled automatically in case of a future update? – ncarrier Mar 29 at 8:14

secretservice requires a GUI. You can use pass without a GUI.

Unfortunately, Docker's documentation on how to configure Docker Credential Helpers is quite lacking. Here's a comprehensive guide how to configure pass with Docker (tested with Ubuntu 18.04):

1. Install the Docker Credential Helper for pass

  • Find the url for the latest version of docker-credential-pass from https://github.com/docker/docker-credential-helpers/releases . For example:
  • # substitute with the latest version
    url=https://github.com/docker/docker-credential-helpers/releases/download/v0.6.2/docker-credential-pass-v0.6.2-amd64.tar.gz
    # download and untar the binary
    wget $url
    tar -xzvf $(basename $url)
    # move the binary to a dir in your $PATH
    sudo mv docker-credential-pass /usr/local/bin
    # verify it works
    docker-credential-pass list
    

    2. Install and configure pass

    apt install pass
    # create a gpg2 key
    gpg2 --gen-key
    # if you have issues with lack of entropy, "apt install haveged" and try again
    # create the password store using the gpg user id above
    pass init $gpg_id
    

    3. docker login

    docker login
    # You should not see any credentials stored in "auths" section.
    # "credsStore": "pass" should have been automatically added.
    # If the value is "secretservice", replace it with "pass".
    cat ~/.docker/config.json
    # verify credentials stored in `pass` store now
    

    There is a much easier answer than the ones already posted, which I found in a comment on https://github.com/docker/docker-credential-helpers/issues/105.

    The solution is to rename docker-credential-secretservice out of the way e.g: mv /usr/bin/docker-credential-secretservice /usr/bin/docker-credential-secretservice.broken

    Once you do this, docker login works regardless of whether or not docker-compose is installed. No other package additions or removals are necessary.

    tried that but now I get `Error saving credentials: error storing credentials - err: exec: "docker-credential-secretservice": executable file not found in $PATH, out: ``` – Stephen Kuehl Jan 10, 2020 at 14:51 Worked for me using aws cli. I'm using an EC2 server launched from an image with docker installed. Each time I start a new instance I have to do this or else I can't authenticate with aws cli. Thanks – robscodebase Mar 26, 2020 at 0:10 Thank you! In my script I move it (as you suggested), do my docker login, then move it back. – Jay Feb 4, 2022 at 15:22 the existence of a package manager is a huge advantage of linux over other operating systems. you usually don't want to install software without your distribution's package manager's awareness, for example by simply downloading software and copy it to /usr/bin or similar. the very obvious reason that you can update all software with just one command, another one is that you can have dependencies on other packages. – msrd0 Nov 2, 2018 at 17:02 I resolved this issue by removing ubuntu from my system and used a system capable of running docker (I'm using debian for stable and fedora for staging). – msrd0 Nov 2, 2018 at 17:03 @msrd0 lack of software isolation introduced by package system is a huge disadvantage of linux and the reason why such "hacks" like docker even exists. Back to the subject: this issue is introduced in Ubuntu package, wipe out Ubuntu is a not solution, so what workaround you are suggesting? – Oleg Neumyvakin Nov 3, 2018 at 7:59 Yes you are absolutely right. Some distributions like fedora ship with selinux, but can't replace isolation done by docker. I asked this question hoping to get a workaround that is acceptable (like changing a config file or similar, not "disabling" the package manager), but haven't found one, so removing ubuntu was the only possible outcome for me – msrd0 Nov 3, 2018 at 10:46 And the nice thing about docker is that you can have a docker-compose.yml, copy that to a different operating system with docker installed, copy the directory with all your docker volumes, and you won't notice any difference to your previous operating system. – msrd0 Nov 3, 2018 at 10:47
  • Following the steps in @oberstet 's post and uninstalling the golang helper
  • Performing a login after the helper uninstall
  • Reinstalling docker via sudo apt-get install docker
  • Logging back in via sudo docker login
  • Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.