本文列舉了幾種情況導致
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)
解決方案
- 檢查
harbor
安裝目錄下harbor.yml
中hostname
值是否爲當前機器的IP地址; - 如果沒有https證書方便訪問,要註釋
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
- 重新登錄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
解決方案
- 檢查
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"
}
- 使用
docker info
查看配置
- 修改
hosts
配置域名訪問。
vi /etc/hosts
# 增加如下地址
192.168.200.128 harbor.tangyuewei.com
- 重新登錄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