4、docker-registry

docker-registry
registry用于保存docker镜像,包括镜像的层次结构和元数据;
用户可以自建registry,也可使用官方的Docker Hub;
分类:
    sponsor registry :第三方的registry,供客户和docker社区使用;
    mirror registry:第三方的registry,只让客户使用;
    vendor registry:由发布docker镜像的供应商提供的registry;
    private registry:通过设有防火墙和额外的安全层的私有实体提供的registry;

安装:
# wget http://mirrors.aliyun.com/repo/Centos-7.repo
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
# yum info docker-registry
# yum install docker-registry
rpm -ql docker-distribution-2.6.2-2.git48294d9.el7.x86_64
/etc/docker-distribution/registry/config.yml  #配置文件
/usr/bin/registry
/usr/lib/systemd/system/docker-distribution.service  #启动服务
/usr/share/doc/docker-distribution-2.6.2
/usr/share/doc/docker-distribution-2.6.2/AUTHORS
/usr/share/doc/docker-distribution-2.6.2/CONTRIBUTING.md
/usr/share/doc/docker-distribution-2.6.2/LICENSE
/usr/share/doc/docker-distribution-2.6.2/MAINTAINERS
/usr/share/doc/docker-distribution-2.6.2/README.md
/var/lib/registry  #镜像存放路径

# cat /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表示监听本机的5000端口

docker-registry启动:
# systemctl start docker-distribution.service
# ss -tnl
State      Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port                            
LISTEN     0      5                          192.168.122.1:53                                                 *:*                  
LISTEN     0      128                                    *:22                                                 *:*                  
LISTEN     0      128                            127.0.0.1:631                                                *:*                             
LISTEN     0      128                                   :::5000                                              :::*                  
LISTEN     0      128                                   :::6443                                              :::*                  
LISTEN     0      128                                   :::2379                                              :::*                  
LISTEN     0      128                                   :::10251                                             :::*                  
LISTEN     0      128                                   :::10252                                             :::*                  
LISTEN     0      128                                   :::8080                                              :::*                  
LISTEN     0      128                                   :::80                                                :::*                  

将镜像推送到docker-registry:
在client端:
# docker tag docker.io/nginx  centos7.cluster.com:5000/nginx:v1.0
# docker push centos7.cluster.com:5000/nginx:v1.0
注:这样推送会报错,Get https://centos7.cluster.com:5000/v1/_ping: ,客户端使用的https协议,而docker-registry使用http

解决方法:
# vi  /etc/docker/daemon.json
        {
            "registry-mirrors": ["https://registry.docker-cn.com"],
             "insecure-registries": ["centos7.cluster.com:5000"]
        }

重启docker服务,重新推送镜像。

在docker-registry服务器上查看推送上来的镜像:
# ls -l /var/lib/registry

 

posted @ 2024-04-09 22:31  Sky-wings  阅读(11)  评论(0编辑  收藏  举报