0
点赞
收藏
分享

微信扫一扫

Docker&Kubernetes ❀ 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


举报

相关推荐

0 条评论