本文列举了几种情况导致
docker
无法登陆harbor
服务器
同一机器,安装了docker和harbor,登陆时报错信息如下
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
[Error response from daemon: Get http://harbor.tangyuewei.com/v2/: Get http://192.168.200.128/service/token?account=admin&client_id=docker&offline_token=true&service=harbor-registry: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
解决方案
harbor
安装目录下harbor.yml
中hostname
值是否为当前机器的IP地址;https
的相关配置,如下图所示;./install.sh
安装并启动。Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-portal ... done
Creating harbor-db ... done
Creating redis ... done
Creating registryctl ... done
Creating registry ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----
hosts
配置域名访问。vi /etc/hosts
# 增加如下地址
192.168.200.128 harbor.tangyuewei.com
root@webster:/usr/local/harbo/harbor# docker login harbor.tangyuewei.com -u admin -p Harbor12345
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
# 结果如上,登录成功
如果此方式执行完毕,还是无法登录。则安装
gnupg2 pass
。
ubuntu
的安装命令为apt install gnupg2 pass
。
参考:https://stackoverflow.com/questions/50151833/cannot-login-to-docker-account
报错信息如下:
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get http://harbor.tangyuewei.com/v2/: Get http://192.168.200.128/service/token?account=admin&client_id=docker&offline_token=true&service=harbor-registry: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
或
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error saving credentials: error storing credentials - err: exit status 1, out: `Cannot autolaunch D-Bus without X11 $DISPLAY`
或
error getting credentials - err: exit status 1, out: `GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files`
如果是使用ip
登录,如:docker login 192.168.200.128 -u admin -p Harbor12345
则可能是这样
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://192.168.200.128/v2/: dial tcp 192.168.200.128:443: connect: connection refused
解决方案
docker
的daemon.json
是否配置了insecure-registries
。配置好后,需要使用systemctl reload docker
重启docker
服务。vi /etc/docker/daemon.json
# 信息如下
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"registry-mirrors": [
"https://20v9zh9c.mirror.aliyuncs.com",
"https://dockerhub.azk8s.cn",
"https://registry.docker-cn.com"
],
"insecure-registries": [
"http://harbor.tangyuewei.com"
],
"storage-driver": "overlay2"
}
vi /etc/hosts
# 增加如下地址
192.168.200.128 harbor.tangyuewei.com
root@jenkins:/usr/local/docker# docker login harbor.tangyuewei.com -u admin -p Harbor12345
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
# 结果如上,登录成功
如果此方式执行完毕,还是无法登录。则安装
gnupg2 pass
。
ubuntu
的安装命令为apt install gnupg2 pass
。
参考:https://stackoverflow.com/questions/50151833/cannot-login-to-docker-account