美文网首页
14-docker系列-docker之harbor仓库的使用

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

作者: 运维家 | 来源:发表于2022-02-21 12:44 被阅读0次

    声明:本文乃“运维家”原创,转载请注明出处,更多内容请关注公众号“运维家”。

    主旨

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

    环境

    linux环境docker环境harbor仓库

    新建用户

    点击 “用户管理” -- “创建用户”

    新建项目并添加成员

    点击 “项目” -- “新建项目”,相关信息配置好之后,点击“确定”按钮

    点击刚才创建的项目

    点击“成员” -- “添加成员”,在这里添加上我们刚新建的用户“yunweijia”,并选择相关角色,不同成员的权限不一致,我这里就配置成“项目管理员”了。

    配置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系列就更新完毕了。各位老板欢迎后台留言想看的内容。

    本文使用 文章同步助手 同步

    相关文章

      网友评论

          本文标题:14-docker系列-docker之harbor仓库的使用

          本文链接:https://www.haomeiwen.com/subject/ugtilrtx.html