博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
docker基础 私有仓库repository搭建(1) registry
阅读量:4037 次
发布时间:2019-05-24

本文共 5059 字,大约阅读时间需要 16 分钟。

分享一下我老师大神的人工智能教程!零基础,通俗易懂!

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

                       
 

使用docker的login命令之后,可以使用push命令将镜像推送到dockerhub上,但是dockerhub毕竟在公网上,免费的帐户只有一个private 的repository是免费的,剩下的就都只能做成public的。由于种种限制,企业私有仓库的创建就有了各种应用场景。本文将从使用registry的方式简单介绍如何搭建私有的repository.

pull registry镜像

 

使用到的registry镜像

[root@liumiaocn ~]# docker search registry |head -n2NAME                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATEDregistry                                  Containerized docker registry                   1123      [OK][root@liumiaocn ~]# docker pull registryUsing default tag: latestlatest: Pulling from library/registryc0cb142e4345: Pull completea5002dfce871: Pull completedf53ce740974: Pull complete9ce080a7bfae: Pull complete517dc3530502: Pull completeDigest: sha256:1cfcd718fd8a49fec9ef16496940b962e30e3927012e851f99905db55f1f4199Status: Downloaded newer image for registry:latest[root@liumiaocn ~]#  
1
2
3
4
5
6
7
8
9
10
11
12
13
14

docker run创建私有仓库

 

registry的介绍提到的最佳实践建议将registry作为容器运行起来。

[root@liumiaocn ~]# docker run -d -p 5000:5000 registrybadf822f34751979e4f7fc513b40177f941b227c7385245ad2f391737587b117[root@liumiaocn ~]# docker psCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMESbadf822f3475        registry            "/entrypoint.sh /etc/"   3 seconds ago       Up 2 seconds        0.0.0.0:5000->5000/tcp   sharp_khorana[root@liumiaocn ~]#  
1
2
3
4
5
6

向私有仓库push一个镜像

 

准备:pull一个busybox

[root@liumiaocn ~]# docker pull busyboxUsing default tag: latestlatest: Pulling from library/busybox56bec22e3559: Pull completeDigest: sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912Status: Downloaded newer image for busybox:latest[root@liumiaocn ~]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZEbusybox             latest              e02e811dd08f        9 days ago          1.093 MBregistry            latest              541a6732eadb        3 weeks ago         33.27 MB[root@liumiaocn ~]#  
1
2
3
4
5
6
7
8
9
10
11
 

准备:tag busybox

[root@liumiaocn ~]# docker tag busybox localhost:5000/busybox[root@liumiaocn ~]# docker imagesREPOSITORY               TAG                 IMAGE ID            CREATED             SIZEbusybox                  latest              e02e811dd08f        9 days ago          1.093 MBlocalhost:5000/busybox   latest              e02e811dd08f        9 days ago          1.093 MBregistry                 latest              541a6732eadb        3 weeks ago         33.27 MB[root@liumiaocn ~]#  
1
2
3
4
5
6
7
 

push推送到私有仓库

[root@liumiaocn ~]# docker push localhost:5000/busyboxThe push refers to a repository [localhost:5000/busybox]e88b3f82283b: Pushedlatest: digest: sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912 size: 527[root@liumiaocn ~]#  
1
2
3
4
5
 

结果确认

[root@liumiaocn ~]# docker imagesREPOSITORY               TAG                 IMAGE ID            CREATED             SIZEbusybox                  latest              e02e811dd08f        9 days ago          1.093 MBlocalhost:5000/busybox   latest              e02e811dd08f        9 days ago          1.093 MBregistry                 latest              541a6732eadb        3 weeks ago         33.27 MB[root@liumiaocn ~]#  
1
2
3
4
5
6

从私库中pull镜像

 

事前准备:将其他镜像都删除,以便确认该镜像确实是从私有仓库中pull出来的

[root@liumiaocn ~]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZEregistry            latest              541a6732eadb        3 weeks ago         33.27 MB[root@liumiaocn ~]#   
1
2
3
4
 

pull 私库镜像

[root@liumiaocn ~]# docker pull localhost:5000/busyboxUsing default tag: latestlatest: Pulling from busybox56bec22e3559: Pull completeDigest: sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912Status: Downloaded newer image for localhost:5000/busybox:latest[root@liumiaocn ~]# docker imagesREPOSITORY               TAG                 IMAGE ID            CREATED             SIZElocalhost:5000/busybox   latest              e02e811dd08f        9 days ago          1.093 MBregistry                 latest              541a6732eadb        3 weeks ago         33.27 MB[root@liumiaocn ~]#  
1
2
3
4
5
6
7
8
9
10
11
 

确认:

  pull下来的image可以正常使用

[root@liumiaocn ~]# docker imagesREPOSITORY               TAG                 IMAGE ID            CREATED             SIZElocalhost:5000/busybox   latest              e02e811dd08f        9 days ago          1.093 MBregistry                 latest              541a6732eadb        3 weeks ago         33.27 MB[root@liumiaocn ~]# docker run -it localhost:5000/busybox /bin/sh/ # hostname24976e98919e/ #  
1
2
3
4
5
6
7
8
 

registry可以用来创建私有仓库,但是其用户管理/图形界面等等方面的功能几乎没有,很不友好, 之前我们也介绍过habor,habor也是建立在registry基础之上的,在接下来的文章中我们会介绍一下如何使用habor。

           

给我老师的人工智能教程打call!

这里写图片描述
你可能感兴趣的文章
fastcgi_param 详解
查看>>
Nginx配置文件(nginx.conf)配置详解
查看>>
标记一下
查看>>
一个ahk小函数, 实现版本号的比较
查看>>
IP报文格式学习笔记
查看>>
autohotkey快捷键显示隐藏文件和文件扩展名
查看>>
Linux中的进程
查看>>
学习python(1)——环境与常识
查看>>
学习设计模式(3)——单例模式和类的成员函数中的静态变量的作用域
查看>>
自然计算时间复杂度杂谈
查看>>
当前主要目标和工作
查看>>
Intellij IDEA启动优化,让开发的感觉飞起来
查看>>
使用 Springboot 对 Kettle 进行调度开发
查看>>
如何优雅的编程,lombok你怎么这么好用
查看>>
一文看清HBase的使用场景
查看>>
除了负载均衡,Nginx还可以做很多,限流、缓存、黑白名单
查看>>
解析zookeeper的工作流程
查看>>
搞定Java面试中的数据结构问题
查看>>
慢慢欣赏linux make uImage流程
查看>>
linux内核学习(7)脱胎换骨解压缩的内核
查看>>