Docker login Harbor报错解决:Error response from daemon: Get https://.. 443: connect: connection refused

报错信息:
[root@localhost harbor]# docker login 172.16.2.15
Username: admin
Password: 
Error response from daemon: Get https://172.16.2.15/v2/: 
dial tcp 172.16.2.15:443: connect: connection refused
查看Docker版本:
[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:27:04 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:25:42 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

停止harbor:
 docker-compose down -v:停止并移除整个project的所有services

[root@localhost harbor]# docker-compose down -v
Stopping harbor-jobservice … done
Stopping nginx … done
Stopping harbor-ui … done
Stopping redis … done

查找docker.service所在位置:
[root@localhost harbor]# find / -name docker.service -type f
/usr/lib/systemd/system/docker.service

修改docker.service配置文件:
 添加 --insecure-registry=172.16.2.15  配置


[root@localhost harbor]# vim /usr/lib/systemd/system/docker.service
[Unit]
Documentation=http://docs.docker.io     //需修改
...
[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 -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry=172.16.2.15  //需修改
ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT   //需修改,根据自己的docker路径跟IP地址进行修改
      
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
...
[Install]
WantedBy=multi-user.target
重启服务:
[root@localhost harbor]# systemctl daemon-reload

[root@localhost harbor]# systemctl restart docker

启动harbor:
 docker-compose up -d :构建(容器)并启动(容器)整个project的所有service

[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

查看服务:
 已经包含了 --insecure-registry=172.16.2.15 参数

[root@localhost harbor]# ps -aux | grep docker

root 40719 1.4 4.8 660304 79992 ? Ssl 01:58 0:14 /usr/bin/dockerd --insecure-registry=172.16.2.15

测试登录:
[root@localhost harbor]# docker login 172.16.2.15
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 //登录成功

成功登录!

你可能感兴趣的:(运维,docker,https,容器)