docker login fails on a server with no X11 installed

穿精又带淫゛_ 提交于 2019-12-03 05:45:36

问题


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?


回答1:


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




回答2:


This works: sudo apt remove golang-docker-credential-helpers




回答3:


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.
cat ~/.docker/config.json

# verify credentials stored in `pass` store now
pass



回答4:


I've resolved this issue by uninstalling docker-compose which was installed from Ubuntu repo and installing docker-compose by official instruction at https://docs.docker.com/compose/install/#install-compose



来源:https://stackoverflow.com/questions/51222996/docker-login-fails-on-a-server-with-no-x11-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!