SpringCloud(第 055 篇)CentOS7 搭建 docker-registry 私有库及管理界面

SpringCloud(第 055 篇)CentOS7 搭建 docker-registry 私有库及管理界面

一、大致介绍

1、基于前面docker的部署,容器一多非常不便于管理,于是急需一个自己的docker私有库;
2、而目前市面上大多数的私有库基本上都是后台服务加前台ui构成,于是选来选去,最后选择了portainer管理界面;
3、之所以选择portainer这款管理界面,我就简述阐述一下,基于以下几点综合考虑而为之:
    3.1 DockerUI 无登录验证,无法权限分配,不支持多主机;
    3.2 Shipyard 支持集群,支持权限分配,启动容器较多,占用每个节点的一部分资源;
    3.3 Portainer 轻量级著称,消耗资源少,虽然功能没有Shipyard强大,但麻雀虽小五脏俱全,满足基本需求;
    3.4 Daocloud 功能强大,部分高级功能收费,安装稍微难度大点,土豪公司无外乎都会选择此项;
4、注意:下面的 my_host_ip 字符串,请大家换成你们自己的宿主机ip地址即可;

二、docker-registry 安装步骤

2.1 搜索docker-registry镜像

// 利用docker搜索命令,看看能搜索包含registry字段的东西,能出来个啥东西
[root@svr01 ~]# docker search registry
INDEX       NAME                                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/registry                                The Docker Registry 2.0 implementation for...   1847      [OK]       
docker.io   docker.io/konradkleine/docker-registry-frontend   Browse and modify your Docker registry in ...   177                  [OK]
docker.io   docker.io/hyper/docker-registry-web               Web UI, authentication service and event r...   123                  [OK]
。。。。。。
docker.io   docker.io/convox/registry                                                                         0                    
docker.io   docker.io/kontena/registry                        Kontena Registry                                0                    
docker.io   docker.io/lorieri/registry-ceph                   Ceph Rados Gateway (and any other S3 compa...   0                    
docker.io   docker.io/mattford63/registry                     The officail docker-registry with python-m...   0  

2.2 拉取docker.io/registry镜像

// 随便拉取了一个指定版本,也可以拉取下来
[root@svr01 ~]# docker pull docker.io/registry:2.3.1
Trying to pull repository docker.io/library/registry ... 
2.3.1: Pulling from docker.io/library/registry
fdd5d7827f33: Pull complete 
a3ed95caeb02: Pull complete 
a79b4a92697e: Pull complete 
6cbb75c7cc30: Pull complete 
4831699594bc: Pull complete 
Digest: sha256:9bd58f43fdf3c378ee7f19ec6e355a5ecbfad8eab82c77079b974b5a78b59e4d
[root@svr01 ~]#
[root@svr01 ~]#
[root@svr01 ~]#
[root@svr01 ~]#
[root@svr01 ~]#

// 获取一个最新的版本,只要网络畅通,基本上都能获取下来
[root@svr01 ~]# docker pull docker.io/registry
Using default tag: latest
Trying to pull repository docker.io/library/registry ... 
latest: Pulling from docker.io/library/registry
81033e7c1d6a: Pull complete 
b235084c2315: Pull complete 
c692f3a6894b: Pull complete 
ba2177f3a70e: Pull complete 
a8d793620947: Pull complete 
Digest: sha256:672d519d7fd7bbc7a448d17956ebeefe225d5eb27509d8dc5ce67ecb4a0bce54
[root@svr01 ~]#
[root@svr01 ~]#
[root@svr01 ~]#
[root@svr01 ~]#
[root@svr01 ~]#

// 查看我们拉取的镜像是否都已经存在本地了
[root@svr01 ~]# docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
docker.io/registry                     latest              d1fd7d86a825        3 weeks ago         33.26 MB
springms/gateway-zuul                  latest              f3825f14878c        6 weeks ago         248.5 MB
springms/provider-user                 latest              5f8a95ffddae        6 weeks ago         270.6 MB
springms/discovery-eureka              latest              825e3f54be46        6 weeks ago         252.5 MB
springms-simple-provider-user          latest              7ccdcdd5270f        6 weeks ago         235.6 MB
springms-user                          latest              4799ed153086        6 weeks ago         235.6 MB
docker.io/centos                       v2                  11efb35f320c        6 weeks ago         307.5 MB
docker.io/frolvlad/alpine-oraclejdk8   latest              4f03dc990224        8 weeks ago         170.1 MB
frolvlad/alpine-oraclejdk8             slim                4f03dc990224        8 weeks ago         170.1 MB
docker.io/centos                       latest              3fa822599e10        8 weeks ago         203.5 MB
docker.io/hello-world                  latest              f2a91732366c        10 weeks ago        1.848 kB
docker.io/registry                     2.3.1               83139345d017        23 months ago       165.8 MB

2.3 启动docker-registry

[root@svr01 ~]# docker run -d -p 5000:5000 --restart=always -v /tmp/docker-var/:/var/lib/registry registry:2.3.1

2.4 访问搭建的镜像仓库

// 通过 curl 命令测试, 正常情况能打印些东西出来
[root@svr01 ~]# curl http://my_host_ip:5000/v2
<a href="/v2/">Moved Permanently</a>.

// 通过浏览器输入 http://my_host_ip:5000/v2 地址试试,正常情况下回输出{}一个空的大括号内容。

2.5 上传测试镜像到镜像仓库中去

// 打一个tag文件
[root@svr01 ~]# docker tag busybox my_host_ip:5000/busybox
[root@svr01 ~]# docker images
REPOSITORY                                        TAG                 IMAGE ID            CREATED             SIZE
my_host_ip:5000/busybox                       latest              5b0d59026729        7 days ago          1.146 MB
docker.io/busybox                                 latest              5b0d59026729        7 days ago          1.146 MB
docker.io/registry                                latest              d1fd7d86a825        3 weeks ago         33.26 MB
springms/gateway-zuul                             latest              f3825f14878c        6 weeks ago         248.5 MB
springms/provider-user                            latest              5f8a95ffddae        6 weeks ago         270.6 MB
springms/discovery-eureka                         latest              825e3f54be46        6 weeks ago         252.5 MB
springms-simple-provider-user                     latest              7ccdcdd5270f        6 weeks ago         235.6 MB
springms-user                                     latest              4799ed153086        6 weeks ago         235.6 MB
docker.io/centos                                  v2                  11efb35f320c        6 weeks ago         307.5 MB
docker.io/frolvlad/alpine-oraclejdk8              latest              4f03dc990224        8 weeks ago         170.1 MB
frolvlad/alpine-oraclejdk8                        slim                4f03dc990224        8 weeks ago         170.1 MB
docker.io/centos                                  latest              3fa822599e10        8 weeks ago         203.5 MB
docker.io/hello-world                             latest              f2a91732366c        10 weeks ago        1.848 kB
docker.io/registry                                2.3.1               83139345d017        23 months ago       165.8 MB
docker.io/konradkleine/docker-registry-frontend   latest              7621ed3504d4        23 months ago       234.9 MB

// push文件到仓库
[root@svr01 ~]# docker push ip:5000/busybox
The push refers to a repository [my_host_ip:5000/busybox]
Get https://my_host_ip:5000/v1/_ping: http: server gave HTTP response to HTTPS client
[root@svr01 ~]# docker push my_host_ip:5000/busybox
The push refers to a repository [my_host_ip:5000/busybox]
Get https://my_host_ip:5000/v1/_ping: http: server gave HTTP response to HTTPS client

// 结果发现出错了, 修改 /etc/docker/daemon.json 文件,支持文件推送
文件内容为:{"insecure-registries":["my_host_ip:5000"]}

// 重启docker
[root@svr01 ~]# service docker restart
Redirecting to /bin/systemctl restart  docker.service
[root@svr01 ~]# 

// 推送文件
[root@svr01 ~]# docker push my_host_ip:5000/busybox
The push refers to a repository [my_host_ip:5000/busybox]
4febd3792a1f: Pushed 
latest: digest: sha256:4cee1979ba0bf7db9fc5d28fb7b798ca69ae95a47c5fecf46327720df4ff352d size: 527
[root@svr01 ~]# 

2.6 查看刚刚推送的busybox文件

[root@svr01 ~]# curl http://my_host_ip:5000/v2/_catalog
{"repositories":["busybox"]}
[root@svr01 ~]# 

2.7 下载刚刚上传的镜像

// 删除已经存在的镜像
[root@svr01 ~]# docker rmi my_host_ip:5000/busybox:latest
Untagged: my_host_ip:5000/busybox:latest
Untagged: my_host_ip:5000/busybox@sha256:4cee1979ba0bf7db9fc5d28fb7b798ca69ae95a47c5fecf46327720df4ff352d
[root@svr01 ~]# 

// 下载镜像
[root@svr01 ~]# docker pull my_host_ip:5000/busybox
Using default tag: latest
Trying to pull repository my_host_ip:5000/busybox ... 
latest: Pulling from my_host_ip:5000/busybox
Digest: sha256:4cee1979ba0bf7db9fc5d28fb7b798ca69ae95a47c5fecf46327720df4ff352d

// 查看一下,my_host_ip:5000/busybox 镜像已经下载下来了
[root@svr01 ~]# docker images
REPOSITORY                                        TAG                 IMAGE ID            CREATED             SIZE
docker.io/busybox                                 latest              5b0d59026729        7 days ago          1.146 MB
my_host_ip:5000/busybox                           latest              5b0d59026729        7 days ago          1.146 MB
docker.io/registry                                latest              d1fd7d86a825        3 weeks ago         33.26 MB
springms/gateway-zuul                             latest              f3825f14878c        6 weeks ago         248.5 MB
springms/provider-user                            latest              5f8a95ffddae        6 weeks ago         270.6 MB
springms/discovery-eureka                         latest              825e3f54be46        6 weeks ago         252.5 MB
springms-simple-provider-user                     latest              7ccdcdd5270f        6 weeks ago         235.6 MB
springms-user                                     latest              4799ed153086        6 weeks ago         235.6 MB
docker.io/centos                                  v2                  11efb35f320c        6 weeks ago         307.5 MB
frolvlad/alpine-oraclejdk8                        slim                4f03dc990224        8 weeks ago         170.1 MB
docker.io/frolvlad/alpine-oraclejdk8              latest              4f03dc990224        8 weeks ago         170.1 MB
docker.io/centos                                  latest              3fa822599e10        8 weeks ago         203.5 MB
docker.io/hello-world                             latest              f2a91732366c        10 weeks ago        1.848 kB
docker.io/registry                                2.3.1               83139345d017        23 months ago       165.8 MB
docker.io/konradkleine/docker-registry-frontend   latest              7621ed3504d4        23 months ago       234.9 MB
[root@svr01 ~]# 

三、portainer管理界面安装

3.1 下载轻量级的管理界面

[root@svr01 ~]# docker pull docker.io/portainer/portainer
Using default tag: latest
Trying to pull repository docker.io/portainer/portainer ... 
latest: Pulling from docker.io/portainer/portainer
d1e017099d17: Pull complete 
d63e75e16ec8: Pull complete 
Digest: sha256:232742dcb04faeb109f1086241f290cb89ad4c0576e75197e902ca6e3bf3a9fc
[root@svr01 ~]# 

3.2 启动 portainer

[root@svr01 ~]# docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name parainer-test docker.io/portainer/portainer

3.3 访问管理界面

浏览器输入 http://my_host_ip:9000/ 然后即可看到UI管理界面;

四、下载地址

https://gitee.com/ylimhhmily/SpringCloudTutorial.git

SpringCloudTutorial交流QQ群: 235322432

SpringCloudTutorial交流微信群: 微信沟通群二维码图片链接

欢迎关注,您的肯定是对我最大的支持!!!

<上一篇        首页        下一篇>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,290评论 4 363
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,399评论 1 294
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,021评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,034评论 0 207
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,412评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,651评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,902评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,605评论 0 199
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,339评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,586评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,076评论 1 261
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,400评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,060评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,083评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,851评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,685评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,595评论 2 270

推荐阅读更多精彩内容