docker无法登陆harbor私服或者远程服务器相关问题

本文列举了几种情况导致docker无法登陆harbor服务器

本机无法登陆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)

解决方案

  1. 检查harbor安装目录下harbor.ymlhostname值是否为当前机器的IP地址;
  2. 如果没有https证书方便访问,要注释https的相关配置,如下图所示;
    在这里插入图片描述
  3. 修改完成后执行./install.sh安装并启动。
  4. 启动成功后,打印信息如下:
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.----
  1. 修改hosts配置域名访问。
vi /etc/hosts
# 增加如下地址
192.168.200.128 harbor.tangyuewei.com
  1. 重新登录habor;
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

其他机器无法登陆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)

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

解决方案

  1. 检查dockerdaemon.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"
}

  1. 使用docker info查看配置
    在这里插入图片描述
  2. 修改hosts配置域名访问。
vi /etc/hosts
# 增加如下地址
192.168.200.128 harbor.tangyuewei.com
  1. 重新登录habor;
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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章