14-docker系列-docker之harbor仓库的使用

网友投稿 789 2022-10-12

本站部分文章、图片属于网络上可搜索到的公开信息,均用于学习和交流用途,不能代表睿象云的观点、立场或意见。我们接受网民的监督,如发现任何违法内容或侵犯了您的权益,请第一时间联系小编邮箱jiasou666@gmail.com 处理。

14-docker系列-docker之harbor仓库的使用

主旨

上一章我们介绍了如何搭建harbor仓库,我们现在看看应该如何进行注册,使用,配置等。

环境

linux环境docker环境harbor仓库

新建用户

新建项目并添加成员

配置http

docker登录仓库默认的方式是https,但是我们一章中创建的是http的,那么我们是不是就无法登录了呢?我们这里来介绍下如何让docker使用http的方式登录仓库。

[yunweijia@localhost harbor]$ sudo vim etc/docker/daemon.json # 第二行是新增的,IP为harbor仓库的访问地址{ "registry-mirrors": ["http://hub-mirror.c.163.com/"],  "insecure-registries": ["192.168.112.130"]}[yunweijia@localhost harbor]$ sudo systemctl restart docker[yunweijia@localhost harbor]$

登录仓库

我们创建完用户之后,需要在linux服务器上进行登录,之后才可以进行上传下载镜像。

[yunweijia@localhost harbor]$ sudo docker login 192.168.112.130Username: yunweijiaPassword: WARNING! Your password will be stored unencrypted in root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded[yunweijia@localhost harbor]$

上传镜像

先查看下系统有多少个镜像

[yunweijia@localhost harbor]$ sudo docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEyunweijia jenkins 976d65da21b9 7 days ago 874MByunweijia python3 31255eafafc3 7 days ago 662MBredis latest f1b6973564e9 3 weeks ago 113MBnginx                           latest     c316d5a335a5   3 weeks ago    142MB[yunweijia@localhost harbor]$

我们选择一个上传,可以先打个tag,这样子他会自行寻找目录,否则你上传的镜像,他都不知道放到哪里,比如下面可以这样子操作;

[yunweijia@localhost harbor]$ sudo docker tag yunweijia:python3 192.168.112.130/yunwei/yunweijia:python3

然后使用push命令进行上传;

[yunweijia@localhost harbor]$ sudo docker push 192.168.112.130/yunwei/yunweijia:python3The push refers to repository [192.168.112.130/yunwei/yunweijia]d05eb0188b0e: Pushed 2ae72c1b8b42: Pushed 661441a515a6: Pushed 174f56854903: Pushed python3: digest: sha256:db23cd3c6e53cac4f76d427b0640ba5e63165c4fde3f73aaeaf36b1a366f2f84 size: 1161[yunweijia@localhost harbor]$

登录harbor仓库里面看看;

下载镜像

查看镜像,看下我们现有多少镜像;

[yunweijia@localhost harbor]$ sudo docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEyunweijia jenkins 976d65da21b9 7 days ago 874MByunweijia python3 31255eafafc3 7 days ago 662MBredis latest f1b6973564e9 3 weeks ago 113MBnginx latest c316d5a335a5 3 weeks ago 142MB[yunweijia@localhost harbor]$

使用pull命令进行下载;

[yunweijia@localhost harbor]$ sudo docker pull 192.168.112.130/yunwei/yunweijia:python3python3: Pulling from yunwei/yunweijiaDigest: sha256:db23cd3c6e53cac4f76d427b0640ba5e63165c4fde3f73aaeaf36b1a366f2f84Status: Downloaded newer image for 192.168.112.130/yunwei/yunweijia:python3192.168.112.130/yunwei/yunweijia:python3[yunweijia@localhost harbor]$

再次查看下镜像,发现已经多了一个下载的镜像;

[yunweijia@localhost harbor]$ sudo docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEyunweijia jenkins 976d65da21b9 7 days ago 874MB192.168.112.130/yunwei/yunweijia python3 31255eafafc3 7 days ago 662MByunweijia python3 31255eafafc3 7 days ago 662MBredis latest f1b6973564e9 3 weeks ago 113MBnginx latest c316d5a335a5 3 weeks ago 142MB[yunweijia@localhost harbor]$

至此,docker系列就更新完毕了。各位老板欢迎后台留言想看的内容。

上一篇:五分钟学会linux磁盘共享之nfs技术
下一篇:k8s系列-01-核心概念
相关文章

 发表评论

暂时没有评论,来抢沙发吧~