首先你需要安裝Harbor服務:
https://blog.csdn.net/qq_50247813/article/details/136388229
客戶端已經安裝docker: https://docs.docker.com/engine/install/centos/
- 在docker客戶端登錄 Harbor
我的
Harbor
服務器地址·:192.168.44.161
賬號密碼為:zoujiahao/Zou#200101
# docker login 192.168.44.161 # docker logout 登出
使用shell方式登錄:
docker login 192.168.44.161 -u zoujiahao -p Zou#200101
# docker login 192.168.44.161
Username: zoujiahao
Password:
Error response from daemon: Get "https://192.168.44.161/v2/": dial tcp 192.168.44.161:443: connect: connection refused
這里報錯的原因也看到了,沒有證書,所以docker客戶端需要將 Harbor 服務器地址添加到不安全的注冊倉庫列表中。
官方文檔參考: https://distribution.github.io/distribution/about/insecure/
-
修改docker /etc/docker/daemon.json文件
# cat /etc/docker/daemon.json {"insecure-registries" : ["192.168.44.161"] }
-
重新加載配置文件,并重啟docker
# systemctl daemon-reload && systemctl restart docker
-
再次登錄
# docker login 192.168.44.161 Username: zoujiahao 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
-
上傳鏡像到 Harbor 倉庫
推送格式在Harbor 倉庫中有介紹
docker tag SOURCE_IMAGE[:TAG] 192.168.44.161/zoujiahao/REPOSITORY[:TAG]
docker push 192.168.44.161/zoujiahao/REPOSITORY[:TAG]
# docker pull busybox
# docker tag busybox 192.168.44.161/zoujiahao/busybox:first
# docker push 192.168.44.161/zoujiahao/busybox:first
# docker push 192.168.44.161/zoujiahao/busybox:first
The push refers to repository [192.168.44.161/zoujiahao/busybox]
2e112031b4b9: Pushed
first: digest: sha256:d319b0e3e1745e504544e931cde012fc5470eba649acc8a7b3607402942e5db7 size: 527
-
在Harbor 控制臺查看
-
重新拉取鏡像
# docker pull 192.168.44.161/zoujiahao/busybox:first