想要嘗試把鏡像推送到自己搭建的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、在 /usr/lib/systemd/system/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 -y
二。刪除 /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
.....
[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個文檔的整合 找的有點多 也不知道哪個和哪個了
