文章目录
docker login 出现错误,提示:Error saving credentials: error storing credentials - err: exit status 1, out: Cannot autolaunch D-Bus without X11 $DISPLAY
环境
使用的是 Mint Linux ,容器为 docker-ce 最新版
| 1 2 3 4  | $ uname -a Linux m01 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux $ docker --version Docker version 18.09.0, build 4d60db4  | 
|---|---|
问题出现
今天在 push 容器镜像时,反复提示没有权限,猜测可能是登陆了其他容器账号验证不过。当我 docker login 后才发现问题并不简单,错误完整提示:
| 1 2 3 4 5  | $ docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: epurs Password: Error saving credentials: error storing credentials - err: exit status 1, out: Cannot autolaunch D-Bus without X11 $DISPLAY  | 
|---|---|
问题解决
再往下看 Issue,感谢 chriswue 给出的详细回答,他提到这是在 Ubuntu (Mint 同样是基于 Ubuntu 的发行版)下使用 docker 特有的 bug ,而修复办法不需要特意去卸载 docker-compose ,只要 “pass” 掉验证步骤。
解决办法:
-  首先安装 gnupg2 和 pass 包,并生成 gpg2 key (我没有用到生成步骤一样可行) 1 sudo apt install gnupg2 pass2 gpg2 --full-generate-key
-  查看生成的 key ,使用 pass加载验证1 gpg2 -k2 pass init "whatever key id you have这里引号中 要填写前面给出的 trustdb.gpg 路径。 
做完上述操作后,再使用 docker login 就没有问题了。