9、Docker私有registry
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的更多相关文章
- 为docker私有registry配置nginx反向代理
公司的Docker私有registry已经搭建好了,用官方的registry image很容易就搭建好了.现在就是要用nginx的反向代理把它放出来,以便在外网可以访问. 我的上一篇blog 讲了如何 ...
- Docker 私有registry出现的证书问题
在上一篇 最近搭建的私有registry里,参考的文章指出,在push时可能出现问题: 可能会出现无法push镜像到私有仓库的问题.这是因为我们启动的registry服务不是安全可信赖的.这是我们需要 ...
- docker 私有registry 配置
备注:此处使用linux镜像配置仓库 registry 启动步骤 https://hub.docker.com/_/registry/ docker login docker pull registr ...
- 7.docker私有registry
一.Docker Registry分类 Registry用于保存docker镜像,包括镜像的层次结构和元数据.都是基于https或者http工作的. 用户可自建Registry,也可使用官方的Dock ...
- Docker 学习9 Docker私有registry
一.docker registry分类 二.安装docker-hub提供的registry 1.安装 [root@localhost yum.repos.d]# yum install -y dock ...
- docker 私有registry harbor安装
一,harbor安装: 参考:Installation and Configuration Guide 1,安装docker 2,安装docker compose sudo curl -L " ...
- docker网络 存储卷 Dockerfile 私有registry
1.bridge模式 docker run --name bu1 -it --network bridge --rm busybox # 相当于 docker run --name bu1 -it - ...
- 建立docker私有库(docker registry)(转)
建立docker私有库(docker registry) 博客分类: docker 我的目标还是无互联网安装,部署内部的docker私有库,目前docker镜像的获得还是需要互联网,将下载好的do ...
- Docker私有仓库 Registry中的镜像管理
这里主要介绍Registry v2的版本 查看Registry仓库中现有的镜像: # curl -XGET http://10.0.30.6:5000/v2/_catalog# curl -XGET ...
随机推荐
- 精心调制的Bash主题分享
第一个是米色背景, 一样遵守蓝色为目录的习惯, 字体为浅灰色,代码和终端看起来相对比较清晰 第二个则是 深海蓝的背景风格,字体都选择饱和度较高的颜色,如下图 终端 配置方法,这里以 mintty 也就 ...
- Android studio 远程服务调用
https://blog.csdn.net/bond_zhe/article/details/50971021
- .net core mysql ef
利用nuget添加以下引用 MySql.Data.EntityFrameworkCore Pomelo.EntityFrameworkCore.MySql Micros ...
- Cookie/Session的机制与安全
转载自:https://harttle.land/2015/08/10/cookie-session.html Cookie和Session是为了在无状态的HTTP协议之上维护会话状态,使得服务器可以 ...
- 批量将PowerDesigner中表字段由小写变成大写
通过以下VB脚本即可批量修改,在Tools=>Execute Commands下的Edit/Run Scripts,或者通过Ctrl+Shift+X运行以下脚本即可: '************ ...
- 框架及其技术(Android)
Log框架: Logger: 简单,漂亮,强大的Android日志工具 Hugo: 在调试版本上注解的触发方法进行日志记录 Timber: 一个小的,可扩展的日志工具 响应式编程: RxJava ...
- 【Solution】API测试工具,访问方式
1. post的时候,@requestBody 用 json的传递方式
- 2018-2019-2 网络对抗技术 20165321 Exp6 信息搜集与漏洞扫描
1.实践目标 掌握信息搜集的最基础技能与常用工具的使用方法. 2.实践内容 (1)各种搜索技巧的应用 百度查找IP地址: 查了一下kali的IP地址 https://fofa.so/的使用: 查询了一 ...
- app ios info权限配置:
info权限配置: Privacy - Bluetooth Peripheral Usage Description --> App需要您的同意,才能访问蓝牙 Privacy - Calenda ...
- WPF中使用DataGrid时操作列按钮问题
在使用DataGrid的过程中,我们有时候需要对选取的某一行数据进行多个操作,这个时候操作列只有一个按钮显然无法满足我们的要求,我们需要多个按钮才能达到我们的目的. UI页面代码: <Grid& ...