当前位置: 首页 > news >正文

docker以distribution和registry管理个人镜像仓库

目录

一.distribution

1.扩展源下载docker-distribution并启动

2.打标签并认证安全仓库

3.推送到私人仓库

4.拉取镜像

二.registry

1.拉取registry的镜像

2.运行容器并打标签

3.认证安全仓库

4.推送到私人仓库

5.拉取镜像


一.distribution

1.扩展源下载docker-distribution并启动

[root@localhost ~]# yum info docker-distribution[root@localhost ~]# yum install -y docker-distribution.x86_64[root@localhost ~]# systemctl start docker-distribution[root@localhost ~]# cd /etc/docker-distribution/registry/[root@localhost registry]# cat config.yml 
version: 0.1
log:fields:service: registry
storage:cache:layerinfo: inmemoryfilesystem:rootdirectory: /var/lib/registry  #默认的镜像存放大致路径
http:addr: :5000   #端口

2.打标签并认证安全仓库

[root@localhost ~]# docker images
REPOSITORY                                           TAG         IMAGE ID       CREATED         SIZE
mysql                                                5.6         dd3b2a5dcb48   20 months ago   303MB
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer   mysql_5.6   dd3b2a5dcb48   20 months ago   303MB
centos                                               latest      5d0da3dc9764   23 months ago   231MB
registry                                             2.6.2       10b45af23ff3   3 years ago     28.5MB
owncloud                                             latest      327bd201c5fb   4 years ago     618MB[root@localhost ~]# docker tag centos:latest 192.168.2.190:5000/centos:latest[root@localhost ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries": ["192.168.2.190:5000"]
}[root@localhost ~]# systemctl restart docker

3.推送到私人仓库

[root@localhost ~]# docker push 192.168.2.190:5000/centos:latest 
The push refers to repository [192.168.2.190:5000/centos]
74ddd0ec08fa: Pushed 
latest: digest: sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3aab063a7fdb9dc size: 529[root@localhost ~]# ll /var/lib/registry/docker/registry/v2/repositories
total 0
drwxr-xr-x 5 root root 55 Aug 25 17:30 centos

4.拉取镜像

[root@localhost ~]# docker pull 192.168.2.190:5000/centos:latest 
latest: Pulling from centos
Digest: sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3aab063a7fdb9dc
Status: Image is up to date for 192.168.2.190:5000/centos:latest
192.168.2.190:5000/centos:latest[root@localhost ~]# docker images
REPOSITORY                                           TAG         IMAGE ID       CREATED         SIZE
mysql                                                5.6         dd3b2a5dcb48   20 months ago   303MB
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer   mysql_5.6   dd3b2a5dcb48   20 months ago   303MB
192.168.2.190:5000/centos                            latest      5d0da3dc9764   23 months ago   231MB
centos                                               latest      5d0da3dc9764   23 months ago   231MB
registry                                             2.6.2       10b45af23ff3   3 years ago     28.5MB
owncloud                                             latest      327bd201c5fb   4 years ago     618MB

二.registry

1.拉取registry的镜像

[root@localhost ~]# systemctl stop docker-distribution.service [root@localhost ~]# docker pull registry:2.6.2

2.运行容器并打标签

-v指定把镜像存储到宿主机的/registry目录下

[root@localhost ~]# docker run -itd --name myregistry -p 5000:5000 -v /registry:/var/lib/registry registry:2.6.2 
a2ddb1f22601398d13dcfcc2f6e495883d5b9cf52fce690eefbe8d0cfc787fd0[root@localhost ~]# docker tag nginx:latest 192.168.2.190:5000/nginx:latest

3.认证安全仓库

[root@localhost ~]# vim /etc/docker/daemon.json 
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries": ["192.168.2.190:5000"]
}[root@localhost ~]# systemctl restart docker

4.推送到私人仓库

[root@localhost ~]# docker push 192.168.2.190:5000/nginx:latest 
The push refers to repository [192.168.2.190:5000/nginx]
563c64030925: Pushed 
6fb960878295: Pushed 
e161c3f476b5: Pushed 
8a7e12012e6f: Pushed 
d0a62f56ef41: Pushed 
4713cb24eeff: Pushed 
511780f88f80: Pushed 
latest: digest: sha256:48a84a0728cab8ac558f48796f901f6d31d287101bc8b317683678125e0d2d35 size: 1778[root@localhost ~]# ll /registry/docker/registry/v2/repositories/
total 0
drwxr-xr-x 5 root root 55 Aug 25 18:09 nginx

5.拉取镜像

[root@localhost ~]# docker pull 192.168.2.190:5000/nginx:latest 
latest: Pulling from nginx
Digest: sha256:48a84a0728cab8ac558f48796f901f6d31d287101bc8b317683678125e0d2d35
Status: Image is up to date for 192.168.2.190:5000/nginx:latest
192.168.2.190:5000/nginx:latest[root@localhost ~]# docker images
REPOSITORY                                           TAG         IMAGE ID       CREATED         SIZE
192.168.2.190:5000/nginx                             latest      eea7b3dcba7e   9 days ago      187MB
nginx                                                latest      eea7b3dcba7e   9 days ago      187MB
mysql                                                5.6         dd3b2a5dcb48   20 months ago   303MB
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer   mysql_5.6   dd3b2a5dcb48   20 months ago   303MB
192.168.2.190:5000/centos                            latest      5d0da3dc9764   23 months ago   231MB
centos                                               latest      5d0da3dc9764   23 months ago   231MB
registry                                             2.6.2       10b45af23ff3   3 years ago     28.5MB
owncloud                                             latest      327bd201c5fb   4 years ago     618MB
http://www.lryc.cn/news/139673.html

相关文章:

  • 2023京东酒类市场数据分析(京东数据开放平台)
  • Android中的APK打包与安全
  • HTTPS单向认证与双向认证
  • (七) ElasticSearch 分词器
  • 足球- EDA的历史数据分析并可视化
  • 用正则处理Unicode 编码的文本
  • 【分布式技术专题】「OSS中间件系列」从0到1的介绍一下开源对象存储MinIO技术架构
  • 生成式人工智能的潜在有害影响与未来之路(三)
  • 【2023钉钉杯复赛】A题 智能手机用户监测数据分析 Python代码分析
  • Django(5)-视图函数和模板渲染
  • Windows下 MySql通过拷贝data目录迁移数据库的方法
  • RabbitMQ---订阅模型-Fanout
  • nginx 中新增url请求参数
  • [系统] 电脑突然变卡 / 电脑突然** / 各种突发情况解决思路
  • 改进YOLO系列:8.添加SimAM注意力机制
  • Go与Rust的对比与分析
  • SpingMVC拦截器-异常处理的思路,用户体验不好的地方
  • 【C++设计模式】用动画片《少年骇客》(Ben10)来解释策略模式
  • 软件测试及数据分析处理实训室建设方案
  • 切换Debian的crontab的nano编辑器
  • Spring Cloud Alibaba-Sentinel--服务容错
  • Stable Diffusion 系列教程 | 如何获得更高清优质的AI绘画
  • 食品饮料制造行业如何实现数字化转型和工业4.0
  • UE学习记录03----UE5.2 使用MVVM示例
  • 代码审计-审计工具介绍-DAST+SAST+IAST项目
  • 网络安全应急响应预案培训
  • STM32F4X 定时器中断
  • MongoDB +Dataframe+excel透视表
  • PostgreSQL日期相关
  • C++编程法则365天一天一条(8)const_cast去除cv限定