Docker Registry

介紹:
  Registry用於保存docker鏡像,包括鏡像的層次結構和元數據
  用戶可自建Registry,也可以使用官方的Docker Hubweb

分類:docker

  • Sponsor Registry: 第三方的registry,供客戶和Docker社區使用
  • Mirror Registry: 第三方的registry,只讓客戶使用
  • Vendor Registry: 由發佈Docker鏡像的供應商提供的registry
  • Private Registry: 經過設有防火牆和額外的安全層的私有實體提供的

安裝docker-resitry:json

~]# yum -y install docker-registry

查看docker-registry安裝後各目錄:vim

~]# rpm -ql docker-registry
/etc/docker-distribution/registry/config.yml                     // registry的配置文件
/usr/bin/registry                             // 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                             // 鏡像所存位置

查看docker-registry的配置文件:緩存

~]# cat /etc/docker-distribution/registy/config.yml
version: 0.1
log:
  fields:
    service: registry
storage:
    cache:
        layerinfo: inmemory              // 緩存在內存中
    filesystem:
        rootdirectory: /var/lib/registry  // 數據存儲路徑
http:
    addr: :5000                        // 監聽端口

啓動服務:安全

~]# systemctl start docker-distribution
~]# ss -nlt | grep 5000
LISTEN     0      128         :::5000                    :::* 

推送鏡像到registry:服務器

~]# docker images
.....
myweb                v0.3-9              7d72ff5e7b03        2 hours ago         16MB
.....
~]# docker tag myweb:v0.3-9 hadoop2:5000/myweb:v0.3-9      // 要將tag改成registry服務器的hostname:port/tag
~]# docker push hadoop2:5000/myweb:v0.3-9 // 推送鏡像到resistry,第一次會報錯,由於客戶端默認使用https協議
  Get https://hadoop2:5000/v2/: http: server gave HTTP response to HTTPS client
~]# vim /etc/docker/daemon.json

  {
    "registry-mirrors": ["https://l10nt4hq.mirror.aliyuncs.com"],   // 鏡像下載加速
    "bip": "10.0.0.1/16",                             // docker橋的地址,新建容器時會依次分配地址
    "hosts": ["tcp://0.0.0.0:2375","unix:///var/run/docker.sock"],     // 容許對外監聽
    "insecure-registries": ["hadoop2:5000"]            // 添加此行
  }tcp

~]# systemctl restart docker     // 重啓服務生效oop

~]# docker push hadoop2:5000/myweb:v0.3-9  // 再次推送,成功spa

~]# ll /var/lib/registry     // 會生成一個docker目錄,數據都在docker目錄下

docker

相關文章
相關標籤/搜索