1. 程式人生 > 其它 >docker login harbor 報錯Error response from daemon: Get https://***/v2/: dial tcp ***:443: connect: connection refused

docker login harbor 報錯Error response from daemon: Get https://***/v2/: dial tcp ***:443: connect: connection refused

想要嘗試把映象推送到自己搭建的harbor上,沒想到在登入harbor的時候死活登入不上,

一直出現harbor 443 connect connection refused

這裡說拒絕連線,因為我是用http部署的harbor,這裡是https://進行訪問的,所有出現報錯

按照網上的兩種操作

1、在/etc/docker/daemon.json的解決辦法:新增 insecure-registries 即可

{
  "registry-mirrors": ["https://1111.aliyuncs.com"],
  "insecure-registries": ["1.1.1.1:80"]
}

2、在docker.service解決辦法:在 ExecStart 新增 --insecure-registry

ExecStart=/usr/bin/dockerd --insecure-registry=1.1.1.1:80

這兩種新增後,發現重啟docker失敗了, 這兩種方法不能同時用。 後面會出現一系列的問題。 最簡單直接的方法

一。如果docker不乾淨。自己改了一大堆東西。 解除安裝docker 重新安裝 (這種解除安裝方法 映象會保留 重新安裝後 只要映象路徑不變 ,映象不會丟失

yum list installed | grep docker
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
docker.x86_64                          
1.7.1-108.el7.centos @extras docker-selinux.x86_64 1.7.1-108.el7.centos @extras [root@localhost ~]# yum -y remove docker.x86_64 [root@localhost ~]# yum -y remove docker-selinux.x86_64
[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io

二。刪除/etc/docker/daemon.json

。加速器自己後期重新配置。 刪除docker裡harbor服務

rm -rf /etc/docker/daemon.json
docker rm -f $(docker ps -qa) # 這是刪除所有的服務

三。配置/usr/lib/systemd/system/docker.service docker配置檔案。 #哪臺要連harbor 就配哪臺

cat /usr/lib/systemd/system/docker.service docker

.....

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --insecure-registry=IP #IP為harbor地址
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

..........

四。重啟docker

[root@localhost]# systemctl daemon-reload
[root@localhost]# systemctl restart docker

五。重新構建harbor

[root@localhost harbor]# docker-compose up -d
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry           ... done
Creating redis              ... done
Creating harbor-db          ... done
Creating harbor-adminserver ... done
Creating harbor-ui          ... done
Creating nginx              ... done
Creating harbor-jobservice  ... done

六。在需要連線harbor的伺服器中檢視是否配置生效

[root@localhost]# ps -aux | grep docker
...
root      40719  1.4  4.8 660304 79992 ?        Ssl  01:58   0:14 /usr/bin/dockerd --insecure-registry=1.1.1.1
...

七。測試登入

[root@localhost harbor]# docker login 1.1.1.1
Username: admin
Password: 
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        //登入成功

此文件轉自網上5.6個文件的整合 找的有點多 也不知道哪個和哪個了