docker login失败问题
Reverse Lv4

问题预览

在尝试使用github 的ghcr.io镜像托管服务时,发现本地 docker 无法正常登录获取权限,如下:

1
2
3
4
╭─root@localhost ~ ‹main●› 
╰─# echo "echo ghp_xxxxxxxx | docker login ghcr.io -u <username> --password-stdin" | zsh

Error saving credentials: error storing credentials - err: exec: "docker-credential-dev-containers-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": executable file not found in $PATH, out: ``

问题定位

尝试读取~/.docker/config.json文件,发现如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
╭─root@localhost ~ ‹main●› 
╰─# cat ~/.docker/config.json 1 ↵
{
"auths": {
"ghcr.io": {
"auth": "xxxxxxxxxx"
},
"registry.cn-hangzhou.aliyuncs.com": {
"auth": "xxxxxxxx"
}
},
"credsStore": "dev-containers-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

其中的credsStore字段指向了一个dev-containers-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx的值,这个值是一个credential helper的ID,用来存储凭证的。

解决办法

直接将~/.docker/config.json文件中的credsStore字段删除掉! 然后再次尝试登录,发现成功了!