Docker 第八章 docker-registry

 

私有倉庫nginx

[root@localhost ~]# yum info docker-registry
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name        : docker-registry
Arch        : x86_64
Version     : 0.9.1
Release     : 7.el7
Size        : 123 k
Repo        : extras/7/x86_64
Summary     : Registry server for Docker
URL         : https://github.com/docker/docker-registry
License     : ASL 2.0
Description : Registry server for Docker (hosting/delivering of repositories and images).

 

[root@localhost ~]# yum install docker-registry -y
[root@localhost ~]# rpm -ql docker-registry
package docker-registry is not installed
[root@localhost ~]# rpm -ql docker-distribution
/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
[root@localhost ~]# 

 

root@localhost registry]# cat config.yml 
version: 0.1
log:
  fields:
    service: registry
storage:
    cache:
        layerinfo: inmemory
    filesystem:
        rootdirectory: /var/lib/registry
http:
    addr: :5000
[root@localhost registry]# 

  

  

啓動服務
[root@localhost registry]# systemctl start docker-distribution

[root@localhost registry]# ss -tnl
State      Recv-Q Send-Q        Local Address:Port                       Peer Address:Port              
LISTEN     0      128                       *:22                                    *:*                  
LISTEN     0      100               127.0.0.1:25                                    *:*                  
LISTEN     0      128                      :::5000                                 :::*                  
LISTEN     0      128                      :::8080                                 :::*                  
LISTEN     0      128                      :::22                                   :::*                  
LISTEN     0      100                     ::1:25                                   :::*                  
[root@localhost registry]# 

 

建立好私有倉庫以後,就能夠使用 docker tag 來標記一個鏡像,而後推送它到倉庫。例如私有倉庫地址爲 127.0.0.1:5000。  git

root@localhost registry]# docker tag httptest:v8.0 127.0.0.1:5000/myhub/ngtest:latest
[root@localhost registry]# ls
config.yml

[root@localhost registry]# docker image ls
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
test                               v1.1                5f393c28297c        24 hours ago        1.2MB
test                               v1.0                3c7f7cac06eb        24 hours ago        1.2MB
ubuntu                             latest              4c108a37151f        32 hours ago        64.2MB
z1                                 latest              4b77198ea96d        45 hours ago        1.2MB
httptest                           v8.0                b42c9ee98879        45 hours ago        1.2MB
127.0.0.1:5000/myhub/ngtest        latest              b42c9ee98879        45 hours ago        1.2MB
httptest                           v7.0                ab2aff8b522c        46 hours ago        1.2MB
httptest                           v6.0                3299492a09ee        46 hours ago        1.2MB
httptest                           v5.0                98ee9a4043f8        46 hours ago        1.2MB
httptest                           v3.0                a1feb6df2fb0        46 hours ago        1.2MB
httptest                           v4.0                a1feb6df2fb0        46 hours ago        1.2MB
httpdtest                          v2.0                f77cae25b226        47 hours ago        2.23MB
httpdtest                          v3                  6060a9cb9597        6 days ago          1.2MB
test                               v2.0                51f46a949468        2 weeks ago         1.2MB
<none>                             <none>              648f9e13a37c        2 weeks ago         1.2MB
zy/busybox                         v0.1                4c9fa4db9491        2 weeks ago         1.2MB
dockerpracticecn/docker_practice   latest              b6bfd54275de        5 weeks ago         41.8MB
busybox                            latest              64f5d945efcc        5 weeks ago         1.2MB
nginx                              latest              53f3fd8007f7        6 weeks ago         109MB
centos                             latest              9f38484d220f        3 months ago        202MB
[root@localhost registry]# docker push 127.0.0.1:5000/myhub/ngtest    #使用docker push 上傳鏡像
The push refers to repository [127.0.0.1:5000/myhub/ngtest]
b5696abb5254: Pushed 
a6f52770da32: Pushed 
d1156b98822d: Pushed 
latest: digest: sha256:3d23b086deb2cde6d8ac2b7c3f5e2040227f0e0914d9002d601c4be314d512a1 size: 941
[root@localhost registry]# 

  

[root@localhost repositories]# pwd    #查看鏡像已經上傳
/var/lib/registry/docker/registry/v2/repositories
[root@localhost repositories]# ls
myhub
[root@localhost repositories]# 

 

注意事項

若是你不想使用 127.0.0.1:5000 做爲倉庫地址,好比想讓本網段的其餘主機也能把鏡像推送到私有倉庫。你就得把例如 192.168.100.100:5000 這樣的內網地址做爲私有倉庫地址,這時你會發現沒法成功推送鏡像。github

這是由於 Docker 默認不容許非 HTTPS 方式推送鏡像。咱們能夠經過 Docker 的配置選項來取消這個限制,docker

Ubuntu 16.04+, Debian 8+, centos 7

對於使用 systemd 的系統,請在 /etc/docker/daemon.json 中寫入以下內容(若是文件不存在請新建該文件)json

{
  "registry-mirror": [ "https://registry.docker-cn.com" ], "insecure-registries": [ "192.168.100.100:5000" ] } 

注意:該文件必須符合 json 規範,不然 Docker 將不能啓動。ubuntu

  

[root@localhost repositories]# cat /etc/docker/daemon.jsion 
{
 "registry-mirrors": ["https://registry.docker-cn.com"]
 }
{
  "dns" : [
    "114.114.114.114",
    "8.8.8.8"
  ],

  "insecure-registries": [              #限制https 選項          
    "192.168.100.100:5000"
  ]
}

[root@localhost repositories]# 

  

 

Nexus3.x 的私有倉庫

可視化的倉庫軟件centos

相關文章
相關標籤/搜索