在没有安装X11的服务器上,docker登录失败

问题描述 投票:8回答:3

我试图在私有docker注册表上部署带有图像的docker配置。

现在,每次执行docker login registry.example.com时,都会收到以下错误消息:

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

我发现非macos用户的唯一解决方案是首先运行export $(dbus-launch),但这并没有改变任何东西。

我正在运行Ubuntu Server并尝试使用Ubuntu Docker软件包和Docker-CE软件包。

如何在没有X11会话的情况下登录?

docker docker-registry ubuntu-server
3个回答
16
投票

看起来这是因为它默认使用secretservice可执行文件,由于某种原因,它似乎具有某种X11依赖性。如果您安装和配置pass docker将使用它而不是似乎解决了问题。

简而言之(来自https://github.com/docker/compose/issues/6023

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

这会生成一个gpg2密钥。完成后,您可以列出它

gpg2 -k

复制密钥ID(从标有[uid]的行)并执行

pass init "whatever key id you have"

现在docker login应该工作。

在启动板上记录了几个关于此的错误:

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

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


6
投票

这有效:sudo apt remove golang-docker-credential-helpers


0
投票

我通过卸载从Ubuntu repo安装的docker-compose并通过docker-compose的官方指令安装https://docs.docker.com/compose/install/#install-compose解决了这个问题


0
投票

secretservice需要一个GUI。你可以在没有GUI的情况下使用pass

不幸的是,Docker的documentation on how to configure Docker Credential Helpers非常缺乏。以下是如何使用Docker配置pass的全面指南(使用Ubuntu 18.04测试):

1. Install the Docker Credential Helper for pass

# 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
© www.soinside.com 2019 - 2024. All rights reserved.