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

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