我有一个试图运行docker login
命令的系统,它是一个 headless 的linux系统,但是不幸的是,仅安装了Docker Credentials Helper docker-credential-secretservice。
这意味着我收到以下错误:
Error saving credentials: error storing credentials - err: exit status 1, out: `Cannot autolaunch D-Bus without X11 $DISPLAY`
我知道这是有道理的:
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. If none of these binaries are present, it stores the credentials (i.e. password) in base64 encoding in the config files described above.
由于
secretservice
helper使用GUI凭据存储,因此它尝试打开一个窗口,该窗口无法在 headless 系统上使用。我无法控制系统,因此无法删除
/usr/bin/docker-credential-secretservice
文件来强制docker login
退回到配置文件,而不是使用secretservice
帮助器。我所能做的就是在用户的主文件夹中创建并列出文件。我试图这样运行命令:
docker --config ./docker login -u <user-name> -p <password> <repository>
我的印象是,登录命令随后将在./docker中创建一个
config.json
(我注意到docker login
将创建该文件夹(如果不存在))。这适用于未安装任何帮助程序的系统,但不适用于有问题的系统。我也尝试过使用类似以下内容创建
~/.docker/config.json
:echo '{"credStore":""}' > ~/.docker/config.json
希望
docker login
会得到提示,不要在凭证存储中使用任何帮助程序。非管理员是否有办法强制
docker login
退回至:stores the credentials (i.e. password) in base64 encoding in the config files described above. Without deleting the credentials helper?
(作为一个旁注,我当然会要求删除
/usr/bin/docker-credential-secretservice
,但是,如果不可能或将来不能使用,是否还有其他解决方案?)
最佳答案
不幸的是,Docker(自18.06起)首先查找docker-credential-*
二进制文件,如果找到其中的任何二进制文件,它将自动覆盖"credsStore"
中的~/.docker/config.json
值。
您唯一的解决方法是在主目录中安装docker-credential-pass
,以便Docker将使用它代替docker-credential-secretservice
。 docker-credential-pass
不需要GUI。
安装docker-credential-pass
的步骤:
docker login fails on a server with no X11 installed
关于docker - 如何强制 'docker login'命令忽略现有的凭据帮助程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55188020/