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

msr*_*rd0 22 ubuntu-server docker docker-registry

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

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

error getting credentials - err: exit status 1, out: `Cannot autolaunch D-Bus without X11 $DISPLAY`
Run Code Online (Sandbox Code Playgroud)

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

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

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

Chr*_*Wue 34

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

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

sudo apt install gnupg2 pass 
gpg2 --full-generate-key
Run Code Online (Sandbox Code Playgroud)

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

gpg2 -k
Run Code Online (Sandbox Code Playgroud)

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

pass init "whatever key id you have"
Run Code Online (Sandbox Code Playgroud)

现在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

  • 谢谢你的回答.我切换到debian,就像他们在我的arch dev机器上工作一样,很遗憾我无法测试你的解决方案 (3认同)
  • 对于我(ubuntu 18.04)来说,“来自标记为‘[uid]’的行”的指令是不正确的,而是需要在标记为‘pub’的条目中查找ID。(但答案仍然有帮助,这只是一个仅供参考,以防其他使用它的人遇到同样的情况) (2认同)

dva*_*urg 18

您可以删除有问题的包,golang-docker-credential-helpers而无需删除所有docker-compose.

以下在没有安装 X11 的服务器上对我有用:

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

Run Code Online (Sandbox Code Playgroud)

进而

echo 'foo' | docker login mydockerrepo.com -u dockeruser --password-stdin
Run Code Online (Sandbox Code Playgroud)

来源:

debian 中报告的 错误:https : //bugs.debian.org/cgi-bin/bugreport.cgi?
bug = 910823#39 ubuntu 上报告的错误:https : //bugs.launchpad.net/ubuntu/+source/docker-撰写/+错误/1796119


obe*_*tet 16

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

  • 此方法有效,并允许您登录,但密码将未加密存储。Docker发出以下通知:`警告!您的密码将以未加密的方式存储在$ HOME / .docker / config.json中。 (5认同)
  • 修复了问题,但也卸载了“docker-compose”。 (5认同)

wis*_*cky 7

secretservice需要一个GUI。您可以pass不使用GUI而使用。

不幸的是,关于如何配置Docker Credential Helpers的 Docker 文档非常缺乏。这是如何pass使用Docker进行配置的综合指南(已在Ubuntu 18.04上进行了测试):

1.安装Docker Credential Helper用于 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
Run Code Online (Sandbox Code Playgroud)

2.安装和配置 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
Run Code Online (Sandbox Code Playgroud)

3. Docker登录

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
Run Code Online (Sandbox Code Playgroud)


小智 7

有一个比已经发布的答案更简单的答案,我在https://github.com/docker/docker-credential-helpers/issues/105的评论中找到了。

解决方案是将 docker-credential-secretservice 重命名,例如: mv /usr/bin/docker-credential-secretservice /usr/bin/docker-credential-secretservice.broken

一旦你这样做了,无论是否安装了 docker-compose,docker login 都会工作。无需添加或删除其他软件包。