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、在 /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个文档的整合 找的有点多 也不知道哪个和哪个了