跳转至

Docker 登录问题

问题1: docker ID无法登录

现象

Bash
1
2
3
4
5
$ sudo 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: lzwang
Password:
Error saving credentials: error storing credentials - err: exit status 1, out: `Unable to obtain authorization for this operation.`

方法

删除保存凭据的文件后,重新登录即可

Bash
sudo rm /usr/local/bin/docker-credential-osxkeychain

问题2: https验证失败

现象

Bash
1
2
3
4
$ docker login https://192.168.x.x:5000
Username: lzwang
Password:
Error response from daemon: Get https://192.168.x.x:5000/v2/: http: server gave HTTP response to HTTPS client

分析

一般存在于私有仓库登录时,提示无法进行https连接,导致登录失败。

方法

更改docker服务的配置,添加对应的"不安全"地址即可:

Bash
vim /etc/docker/daemon.json

添加如下一行内容:

JSON
1
2
3
{
  "insecure-registries": ["192.168.x.x:5000"]
}

记得重启docker服务:

Bash
systemctl restart docker

参考