Docker Registry分类

Docker 默认是使用https的,但是如果在自己得私有局域网中,你指明使用http也是可以的。

Registry主要的作用是托管镜像;

运行docker registry的方式一:

registry运行在容器中,容器的文件是随着容器的消息而被删除。所以要为registry定义一个存储卷,这个存储卷不要放在docker host本地,而是要使用网络存储。

运行docker registry的方式二演示:

注意在node2上创建

[root@node2 ~]# yum info docker-registry   //查看registry的版本号

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors..com
* epel: mirror.lzu.edu.cn
* extras: mirrors..com
* updates: mirror.lzu.edu.cn
Available Packages
Name : docker-registry
Arch : x86_64
Version : 0.9.
Release : .el7
Size : k
Repo : extras//x86_64
Summary : Registry server for Docker
URL : https://github.com/docker/docker-registry
License : ASL 2.0
Description : Registry server for Docker (hosting/delivering of repositories and images).

[root@node2 ~]# yum install docker-registry

虽然安装的是rigstry,但是包名是 docker-ditribution 上述版本与docker官网的最新版本相差无几 https://hub.docker.com/_/registry?tab=tags;

[root@node2 ~]# rpm -ql docker-distribution

/etc/docker-distribution/registry/config.yml   //配置文件
/usr/bin/registry
/usr/lib/systemd/system/docker-distribution.service
/usr/share/doc/docker-distribution-2.6.
/usr/share/doc/docker-distribution-2.6./AUTHORS
/usr/share/doc/docker-distribution-2.6./CONTRIBUTING.md
/usr/share/doc/docker-distribution-2.6./LICENSE
/usr/share/doc/docker-distribution-2.6./MAINTAINERS
/usr/share/doc/docker-distribution-2.6./README.md
/var/lib/registry //存放数据路径

[root@node2 ~]# vim /etc/docker-distribution/registry/config.yml

version: 0.1
log:
fields:
service: registry //服务
storage:
cache:
layerinfo: inmemory //缓存在内存中
filesystem:
rootdirectory: /var/lib/registry //数据存储路径
http:
addr: :5000 //5000是端口,地址没有给出表示本机所有可用地址,这里是http协议,标准端口应该是80端口,如果是https协议则标准端口是443

[root@node2 ~]# systemctl start docker-distribution

[root@node2 ~]# ss -tnl | grep 5000
       LISTEN              0           128             :::5000          :::*

以上docker私有仓库就准备好了

[root@node1 ~]# docker image ls   //显示node1制作的镜像,把node1服务器上的镜像poll到node2的仓库里面

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tinyhttpd v0.- c0c7f3d670e2 hours ago .28MB //tinyhttpd这里标记的都是docker hub的标记,而且是顶层仓库,是无法直接推到私有仓库的,要打标
tinyhttpd v0.- 31c87ab706ef hours ago .27MB
tinyhttpd v0.- 182fd6cb55e0 hours ago .27MB
tinyhttpd v0.- a4edf21d7f10 hours ago .27MB
tinyhttpd v0.- ffd35e42c975 hours ago .29MB
tinyhttpd v0.- 36fff46e7087 hours ago .24MB
tinyhttpd v0.- 948f2959ddb4 days ago .22MB
tinyhttpd v0.- 026022e873de days ago .2MB
beisen/httpd v0. bf9c668b1196 weeks ago .2MB
beisen/httpd v0.- 9a9506b58e22 weeks ago .2MB
nginx 1.14-alpine cafef9fe265b weeks ago 16MB
redis -alpine 1e985c88d45b weeks ago .5MB
busybox latest d8233ab899d4 weeks ago .2MB

[root@node2 ~]# ifconfig  //要使用node2上对外通信的IP地址,非docker hub就必须给出docker registry的服务器地址、端口。

[root@node1 ~]# docker tag tinyhttpd:v0.1-10 node2:5000/tinyhttpd:v0.1-10   //在node1上打标,加红加粗部分(tinyhttpd表示顶层仓库)表示顶层仓库

[root@node1 ~]# docker image ls

node2:5000/tinyhttpd   v0.1-10             c0c7f3d670e2        28 hours ago        8.28MB   //查看打包的镜像

[root@node1 ~]# docker push node2:5000/tinyhttpd:v0.1-10    //往node2中推送镜像,这里由于只有一个镜像,标签(v0.1-10)可要可不要,如果不给标签,则推送整个仓库。
    The push refers to repository [node2:5000/tinyhttpd]
    Get https://node2:5000/v2/: http: server gave HTTP response to HTTPS client   //这里报错,因为docker默认是https协议,此处客户端是http协议,而服务器端是https协议。

由于本次演示是在内网,所以可以不使用https协议,要使用http协议必须进行配置,把它标记为非加密非安全的docker registry。

官方手册(完整的可用参数列表):

https://docs.docker.com/engine/reference/commandline/dockerd/#run-multiple-daemons

"insecure-registries": [],   //把此项添加到/etc/docker/daemon.json

[root@node1 ~]# vim /etc/docker/daemon.json    //在node1中进行配置

{
"registry-mirrors": ["https://registry.docker-cn.com"],
"insecure-registries": ["node2:5000"], //添加此行
"bip": "10.0.0.1/16"
}

[root@node1 ~]# systemctl restart docker   //注意这里更改的是node1,相对于docker registry(node2是服务器端),node1是客户端。

[root@node1 ~]# docker push node2:5000/tinyhttpd:v0.1-10   //此时就可以成功了

The push refers to repository [node2:/tinyhttpd]
199778bdbe15: Pushed //这表示一层,每一层都单独存放
9cf8d73c614a: Pushed
868d862401c1: Pushed
adab5d09ba79: Pushed
v0.-: digest: sha256:3bd3dc5a7295ab9a2affbf7793e1dc1272f515c5aeec3d3417907b15c6d1ad04 size:

[root@node2 ~]# cd /var/lib/registry/docker/registry/v2/repositories/tinyhttpd/_
   _layers/ _manifests/ _uploads/
[root@node2 ~]# cd /var/lib/registry/docker/registry/v2/repositories/tinyhttpd/_layers/sha256/
   66bf463ec427c266523a37e3c405c5d40d1a20f5f7b40c8f26fa11cc27ed82ac/
   697743189b6d255069caf6c455be10c7f8cae8076c6f94d224ae15cd41420e87/
   92dba7e5a2cbf2a9550b8783ef02210c6c2a00b45b621ba8b00af7bb9da3bb58/
   c0c7f3d670e214de0dfaa3dee5907591308ca123746066e1c1245263277fd815/
   e535bb7265a642ef3cc982d8e80bcf2559ff3cef66be8bfcc2758a77fca7d947/

[root@node2 ~]# ls /var/lib/registry/docker/registry/v2/repositories/tinyhttpd/_layers/sha256/66bf463ec427c266523a37e3c405c5d40d1a20f5f7b40c8f26fa11cc27ed82ac
   link    //此处就是链接到node1中

如果想在node2上下载刚才push的镜像,同时使用http服务,就需要对node2上的配置文件进行更改。

[root@node2 ~]# vim /etc/docker/daemon.json

9、Docker私有registry的更多相关文章

  1. 为docker私有registry配置nginx反向代理

    公司的Docker私有registry已经搭建好了,用官方的registry image很容易就搭建好了.现在就是要用nginx的反向代理把它放出来,以便在外网可以访问. 我的上一篇blog 讲了如何 ...

  2. Docker 私有registry出现的证书问题

    在上一篇 最近搭建的私有registry里,参考的文章指出,在push时可能出现问题: 可能会出现无法push镜像到私有仓库的问题.这是因为我们启动的registry服务不是安全可信赖的.这是我们需要 ...

  3. docker 私有registry 配置

    备注:此处使用linux镜像配置仓库 registry 启动步骤 https://hub.docker.com/_/registry/ docker login docker pull registr ...

  4. 7.docker私有registry

    一.Docker Registry分类 Registry用于保存docker镜像,包括镜像的层次结构和元数据.都是基于https或者http工作的. 用户可自建Registry,也可使用官方的Dock ...

  5. Docker 学习9 Docker私有registry

    一.docker registry分类 二.安装docker-hub提供的registry 1.安装 [root@localhost yum.repos.d]# yum install -y dock ...

  6. docker 私有registry harbor安装

    一,harbor安装: 参考:Installation and Configuration Guide 1,安装docker 2,安装docker compose sudo curl -L " ...

  7. docker网络 存储卷 Dockerfile 私有registry

    1.bridge模式 docker run --name bu1 -it --network bridge --rm busybox # 相当于 docker run --name bu1 -it - ...

  8. 建立docker私有库(docker registry)(转)

    建立docker私有库(docker registry) 博客分类: docker   我的目标还是无互联网安装,部署内部的docker私有库,目前docker镜像的获得还是需要互联网,将下载好的do ...

  9. Docker私有仓库 Registry中的镜像管理

    这里主要介绍Registry v2的版本 查看Registry仓库中现有的镜像: # curl -XGET http://10.0.30.6:5000/v2/_catalog# curl -XGET ...

随机推荐

  1. C++ opencv调用resize修改插值方式遇到的坑

    opencv提供的热死则函数原型如下:void resize(InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0 ...

  2. 当使用eclipse将项目部署到Tomcat时,提示Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modul

    原因: 此版本选择过高.当出现此错误时,直接对项目可能无法进行修改.可以通过修改项目的配置文件来达到目的. \workspace\项目名称\.settings\org.eclipse.wst.comm ...

  3. - configuration.module has an unknown property 'loader' 问题解决

    错误提示: Invalid configuration object. Webpack has been initialised using a configuration object that d ...

  4. 18. C# 转换

    1.重载转换运算符 到目前为止,我们使用的类型转换,包括隐式类型转换和显示类型转换都是在两个相关的类中进行的,这几个类要么是简单类型之间的转换,比如int 隐式转换成double,要么是有继承关系,或 ...

  5. 《ASP.NET Core In Action》读书笔记系列,这是一个手把手的从零开始的教学系列目录

    最近打算系统学习一下asp.net  core ,苦于没有好的中文书藉,只好找来一本英文的 <ASP.NET Core In Action>学习.我和多数人一样,学习英文会明显慢于中文.希 ...

  6. TCP连接状态管理

    tcp 连接过程 tcp 状态机

  7. 练手——用Python写的时间戳转换为北京时间的小工具

    #北京时间需加上8小时bj = 8*3600 def time_stamp(times):    #一天总秒数    nonDaySeconds = 24*3600    leapmonths = [ ...

  8. redis使用总结(一)(redis客户端使用)

    NoSQL 摘自百度百科 NoSQL,泛指非关系型的数据库.随着互联网web2.0网站的兴起,传统的关系数据库在应付web2.0网站,特别是超大规模和高并发的SNS类型的web2.0纯动态网站已经显得 ...

  9. PLS-00357: Table,View Or Sequence reference 'SEQ_TRADE_RECODE.NEXTVAL' not allowed in this context

    oracle数据库: 为了使ID自增,建了序列后,创建触发器: create or replace TRIGGER TRIG_INSERT_TRADE_RECODE BEFORE INSERT ON ...

  10. vue 脚手架关于路由的一点理解

    https://router.vuejs.org/zh/ 可以先翻翻文档看看介绍啊,一般我不怎么喜欢看文档,都是直接看人家案例,在回头看文档的,所以学习速度慢很多,希望我以后成为一个爱学习的妹子,比较 ...