報錯資訊:
[root@localhost harbor]# docker login 192.168.2.195
Username: admin
Password:
Error response from daemon: Get https://192.168.2.195/v2/:
dial tcp 192.168.2.195: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=192.168.2.195 配置
[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
ExecStart=/usr/bin/dockerd --insecure-registry=192.168.2.195 //重要
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=192.168.2.195 參數
[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=192.168.2.195
...
複制
測試登入:
[root@localhost harbor]# docker login 192.168.2.195
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 //登入成功
複制
成功登入!