今天遇到一个问题,当我通过 ssh 连接另一台 mac 执行 docker login 时报错,内容如下:
$ 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: keinos
Password:
Error saving credentials: error storing credentials - err: exit status 1, out: `error storing credentials - err: exit status 1, out: `User interaction is not allowed.``
原因是 mac 上运行 docker login 会将登陆信息保存在钥匙串,由于钥匙串的默认保护机制被触发, ssh 连接状态下无法操作钥匙串,所以返回这个错误。
解决的办法就是解除这个限制,只需要先执行如下命令
security unlock-keychain
但是这只能使本次 session 内有效,于是我找到了另一个解决方案:
编辑 ~/.docker/config.json
删除 osxkeychain
将 credsStore 的值改为 “”