栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Cloud ❀ 构建Docker官方仓库Registry教程

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Cloud ❀ 构建Docker官方仓库Registry教程

文章目录
  • 1、下载镜像
  • 2、修改配置文件
  • 3、构建自定义镜像
  • 4、客户端下载私有仓库镜像

1、下载镜像

仓库镜像下载

[root@Redhat8 ~]# docker pull registry
[root@Redhat8 ~]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED        SIZE
registry                        latest    b2cb11db9d3d   3 weeks ago    26.2MB

部署仓库容器

[root@Redhat8 ~]# docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always registry
[root@localhost ~]# docker ps
]ConTAINER ID   IMAGE      COMMAND                  CREATED          STATUS          PORTS                                       NAMES
8239e077d1b8   registry   "/entrypoint.sh /etc…"   22 minutes ago   Up 18 minutes   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp   ecstatic_bouman
2、修改配置文件

默认镜像下载端口为443,此处修改为5000,需要在配置文件内进行说明;

[root@Redhat8 ~]# cat /etc/docker/daemon.json
{  
     "registry-mirrors": ["https://sta7qavr.mirror.aliyuncs.com"]  
     "insecure-registries": ["10.81.20.166:5000"]
}

配置文件修改后需要重启服务

[root@localhost ~]# systemctl restart docker
3、构建自定义镜像

查看已有镜像

[root@Redhat8 ~]# docker images | grep centos
REPOSITORY                      TAG       IMAGE ID       CREATED        SIZE
centos                          latest    300e315adb2f   9 months ago   209MB

构建上传到私有仓库的自定义镜像
镜像构建格式:仓库地址/username/image:tag

[root@Redhat8 ~]# docker tag centos:latest 10.81.20.166:5000/centos:latest
[root@Redhat8 ~]# docker images | grep centos
REPOSITORY                      TAG       IMAGE ID       CREATED        SIZE
10.81.20.166:5000/centos        latest    300e315adb2f   9 months ago   209MB
centos                          latest    300e315adb2f   9 months ago   209MB

上传到私有仓库

[root@localhost ~]# docker push 10.81.20.166:5000/centos:latest
The push refers to repository [10.81.20.166:5000/centos]
74ddd0ec08fa: Pushed 
latest: digest: sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3aab063a7fdb9dc size: 529

查看私人仓库的已有镜像

[root@localhost ~]# curl -XGET http://10.81.20.166:5000/v2/_catalog
{"repositories":["centos"]}
4、客户端下载私有仓库镜像

首先也需要修改容器仓库下载端口,配置同第二节内容;

[root@Redhat8 ~]# cat /etc/docker/daemon.json
{  
     "insecure-registries": ["10.81.20.166:5000"]
}

配置文件修改后需要重启服务

[root@localhost ~]# systemctl restart docker

下载私人仓库镜像

[root@localhost ~]# docker pull 10.81.20.166:5000/centos:latest

查看下载的镜像

[root@localhost ~]# docker images | grep centos
10.81.20.166:5000/centos   latest    5d0da3dc9764   12 days ago   231MB
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/345582.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号