首先你需要安装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