zoukankan      html  css  js  c++  java
  • DockerHub加速及私有镜像搭建&RESTAPI

    Docker Hub加速及私有镜像搭建&REST API


    daocloud加速
    说明:国内的daocloud,时速云(tenxcloud.com),灵雀云(http://www.alauda.cn/)都只是一部分同步Docker Hub官方,但聊胜于无
    1.安装docker
    2.注册并登录daocloud账号
    DockerHub加速及私有镜像搭建&RESTAPI

    3.配置加速
    A.加速2.0(安装daomonit)
    实现加速后,只要本地网速够快,下载速度可以达到1MB哦,比Docker Hub官方已经快上N个级别了,实测,1分钟内即可pull完ubuntu:16.04

    curl -sSL https://get.daocloud.io/daomonit/install.sh | sh -s 25862a99e83db9287676008adbb7c38f10dea220

    [root@ct7 ~]# dao pull ubuntu:16.04

    Dao from DaoCloud

    Initializing, Please wait a minute

    Using default tag: latest

    latest: Pulling from daocloud/daocloud-toolset


    efd26ecc9548: Pull complete 

    a3ed95caeb02: Pull complete 

    2719467b8a13: Pull complete 

    b77ed3a436e2: Pull complete 

    Digest: sha256:09de57ef521f2d8c056b95bafc36ccbcb900b3bdcd5e5c917714d26fca26e944

    Status: Downloaded newer image for daocloud.io/daocloud/daocloud-toolset:latest

    Inital Success



    # ----------------------------------------------------------------------------

    # DaoCloud ToolBox for Docker

    #

    # DaoCloud, Inc. (c) 2016

    #

    # Fastest way to pull image from Docker Hub

    # ----------------------------------------------------------------------------


    Pulling repository library/ubuntu:16.04 

    ac6ad7efd0f9: Download complete                                                                     a3ed95caeb02: Download complete                                                                                Download complete                                                                     5ba4f30e5bea: Download complete                                                                                   Download complete                                                                     Pull library/ubuntu:16.04 complete, you can find it with 'docker images'   

    [root@ct7 ~]# docker images

    REPOSITORY                              TAG                 IMAGE ID            CREATED             SIZE

    ubuntu                                  16.04               1cdafc116f5e        12 days ago         122 MB

    daocloud.io/daocloud/daocloud-toolset   latest              1ab33797d8a1        6 weeks ago         150.2 MB


    B.加速1.0(推荐)

    加速1.0更容易明白加速原理,也更原生些。实际上是启动docker daemon时通过--registry-mirror优先指定Registry,可以指定多条

    sed -i 's#fd://#fd:// --registry-mirror http://1257c036.m.daocloud.io#' /lib/systemd/system/docker.service

    systemctl daemon-reload

    systemctl restart docker


    [root@ct7 ~]# systemctl status docker

    docker.service - Docker Application Container Engine

       Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)

       Active: active (running) since 四 2016-06-09 02:10:00 CST; 9min ago

         Docs: https://docs.docker.com

     Main PID: 14191 (docker)

       CGroup: /system.slice/docker.service

               ├─14191 /usr/bin/docker daemon -H fd:// --registry-mirror http://1257c036.m.daocloud.i...

               └─14196 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --ru...


    6月 09 02:10:00 ct7.example.com docker[14191]: time="2016-06-09T02:10:00.987206124+08:00" lev...nd"

    6月 09 02:10:00 ct7.example.com docker[14191]: time="2016-06-09T02:10:00.987503747+08:00" lev...t."

    6月 09 02:10:00 ct7.example.com docker[14191]: time="2016-06-09T02:10:00.987564135+08:00" lev...e."

    6月 09 02:10:00 ct7.example.com docker[14191]: time="2016-06-09T02:10:00.987573388+08:00" lev...on"

    6月 09 02:10:00 ct7.example.com docker[14191]: time="2016-06-09T02:10:00.987583790+08:00" lev...1.2

    6月 09 02:10:00 ct7.example.com docker[14191]: time="2016-06-09T02:10:00.992688671+08:00" lev...ck"

    6月 09 02:10:00 ct7.example.com systemd[1]: Started Docker Application Container Engine.

    6月 09 02:10:25 ct7.example.com docker[14191]: time="2016-06-09T02:10:25.881743515+08:00" lev...wn"

    6月 09 02:10:43 ct7.example.com docker[14191]: time="2016-06-09T02:10:43.704859767+08:00" lev...ed"

    6月 09 02:10:46 ct7.example.com docker[14191]: time="2016-06-09T02:10:46.772210349+08:00" lev...nd"

     

    Hint: Some lines were ellipsized, use -l to show in full.




    搭建私有Registry2.x

    A.Docker Hub官方Registry容器

    1.运行registry容器(run)

    docker run -d -p 5000:5000 --restart=always --name registry -v /var/lib/docker/registry:/var/lib/registry registry:2

    说明:前提docker版本要1.6或更新,运行后会自动下载并启动一个registry容器。默认会将仓库创建在容器的/tmp/registry目录下,-v 参数可以指定镜像文件存放的本地的路径

    [root@ct7 ~]# docker version

    Client:

     Version:      1.11.2

     API version:  1.23

     Go version:   go1.5.4

     Git commit:   b9f10c9

     Built:        Wed Jun  1 21:23:11 2016

     OS/Arch:      linux/amd64


    Server:

     Version:      1.11.2

     API version:  1.23

     Go version:   go1.5.4

     Git commit:   b9f10c9

     Built:        Wed Jun  1 21:23:11 2016

     OS/Arch:      linux/amd64

    [root@ct7 ~]# docker run -d -p 5000:5000 --restart=always --name registry -v /var/lib/docker/registry:/var/lib/registry registry:2

    Unable to find image 'registry:2' locally

    2: Pulling from library/registry

    51f5c6a04d83: Pull complete 

    a3ed95caeb02: Pull complete 

    c8064261a06d: Pull complete 

    619635144a24: Pull complete 

    c0275d66d860: Pull complete 

    Digest: sha256:33ea1d7ad2af5ac5d984fe34a6491ce1505f11e46a60dbf99147a5879407d703

    Status: Downloaded newer image for registry:2

    f099ef927cbf4e56b6479647adc68060d67ce9f17c9f7e4ecdb660f05254ca74

    [root@ct7 ~]# docker ps

    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES

    f099ef927cbf        registry:2          "/bin/registry serve "   3 minutes ago       Up 3 minutes        0.0.0.0:5000->5000/tcp   registry

    [root@ct7 ~]# netstat -tunlp|grep docker

    tcp6           0 :::5000                 :::*                    LISTEN      2661/docker-proxy 


    图形界面 https://hub.docker.com/r/hyper/docker-registry-web/


    2.获取image(pull)

    docker pull ubuntu:16.04


    [root@ct7 ~]# docker pull ubuntu:16.04

    16.04: Pulling from library/ubuntu

    5ba4f30e5bea: Pull complete 

    9d7d19c9dc56: Pull complete 

    ac6ad7efd0f9: Pull complete 

    e7491a747824: Pull complete 

    a3ed95caeb02: Pull complete 

    Digest: sha256:f5edf3b741a08b573eca6bf25257847613540538a17b86e2b76e14724a0be68a

    Status: Downloaded newer image for ubuntu:16.04

    3.将获取到的image tag到私有registry(tag)

    docker tag ubuntu:16.04 localhost:5000/ubuntu:16.04

    4.将获取到的image push到私有registry(push)

    docker push localhost:5000/ubuntu:16.04


    [root@ct7 ~]# docker push localhost:5000/ubuntu:16.04

    The push refers to a repository [localhost:5000/ubuntu]

    5f70bf18a086: Pushed 

    737f40e80b7f: Pushed 

    82b57dbc5385: Pushed 

    19429b698a22: Pushed 

    9436069b92a3: Pushed 

    16.04: digest: sha256:4cd13bd37c4cc65e03cec3701b447654a979291c6e1fde25d40023ad37876d34 size: 1356

    5.stop/rm registry容器

    停止registry容器

    docker stop registry 

    删除registry容器

    docker rm -fv registry

    6.指定docker私有镜像

    https://docs.docker.com/engine/reference/commandline/daemon/#insecure-registries

    sed -i 's#fd://#fd:// --registry-mirror http://192.168.8.254:5000 --insecure-registry 192.168.8.254:5000#' /lib/systemd/system/docker.service

    systemctl daemon-reload

    systemctl restart docker

    注意:如果私有registry没有TLS加密,则客户端在启动docker时要加上--insecure-registry参数,否则pull,push等都会失败

    [root@ct7 ~]# docker pull 192.168.8.254:5000/ubuntu:14.04

    Error response from daemon: Get https://192.168.8.254:5000/v1/_ping: tls: oversized record received with length 20527

    配置正确的话,会如下输出

    [root@ct7 ~]# docker pull 192.168.8.254:5000/centos:7

    7: Pulling from centos


    488a93afa07d: Pull complete 

    Digest: sha256:88dcdb9b54988129d4b63d984236f9b14dcc0c2dd1f77cd33d3673d888c18079

    Status: Downloaded newer image for 192.168.8.254:5000/centos:7

    [root@ct7 ~]# docker images

    REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE

    192.168.8.254:5000/centos   7                   7d957a47f7fd        About an hour ago   434.8 MB

    [root@ct7 ~]# docker run -t -i 192.168.8.254:5000/centos:7 /bin/bash

    或者直接

    [root@ct7 ~]# docker run -dti 192.168.8.254:5000/centos:7 /bin/bash

    Unable to find image '192.168.8.254:5000/centos:7' locally

    7: Pulling from centos


    488a93afa07d: Pull complete 

    Digest: sha256:88dcdb9b54988129d4b63d984236f9b14dcc0c2dd1f77cd33d3673d888c18079

    Status: Downloaded newer image for 192.168.8.254:5000/centos:7

    2fcd581979e9be74cf15b51b3e29c96a930b2a57075aee21bac577ab5eec4049

    [root@ct7 ~]# docker ps

    CONTAINER ID        IMAGE                         COMMAND             CREATED              STATUS              PORTS               NAMES

    2fcd581979e9        192.168.8.254:5000/centos:7   "/bin/bash"         About a minute ago   Up About a minute                       prickly_northcutt

     

    [root@ct7 ~]# docker attach 2fcd581979e9

    [root@243ae3584729 /]# cd

    [root@243ae3584729 ~]# uname -a

    Linux 243ae3584729 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

    [root@243ae3584729 ~]# cat /etc/redhat-release 

    CentOS Linux release 7.2.1511 (Core) 

    [root@243ae3584729 ~]# ip a

    1: lo: mtu 65536 qdisc noqueue state UNKNOWN 

        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

        inet 127.0.0.1/8 scope host lo

           valid_lft forever preferred_lft forever

        inet6 ::1/128 scope host 

           valid_lft forever preferred_lft forever

    4: eth0: mtu 1500 qdisc noqueue state UP 

        link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff

        inet 172.17.0.2/16 scope global eth0

           valid_lft forever preferred_lft forever

        inet6 fe80::42:acff:fe11:2/64 scope link 

           valid_lft forever preferred_lft forever

    7.导入image

    如果觉得官方镜像慢除了指定国内docker镜像源加速外还可以自行打包镜像或借助开源模板http://openvz.org/Download/template/precreated
    openvz的镜像虽不算快,但比docker官方站点要快许多

    cat centos-7-x86_64-minimal.tar.gz|docker importcentos:7
    docker tag centos:7 localhost:5000/centos:7
    docker push localhost:5000/centos:7

    docker import ubuntu-14.04-x86_64-minimal.tar.gz ubuntu:14.04

    docker tag ubuntu:14.04 localhost:5000/ubuntu:14.04

    docker push localhost:5000/ubuntu:14.04


    docker import http://download.openvz.org/template/precreated/ubuntu-16.04-x86_64.tar.gz ubuntu:16.04

    docker tag ubuntu:16.04 localhost:5000/ubuntu:16.04

    docker push localhost:5000/ubuntu:16.04


    提示:导入本地镜像需要先import--->tag--->push

    root@router:~#docker import  centos-7-x86_64-minimal.tar.gz centos:7

    sha256:7d957a47f7fd2a7ea8353e452e9cbda56c22724cff925094b0a078bfd14c5a21

    root@router:~#docker tag centos:7 localhost:5000/centos:7

    root@router:~#docker push localhost:5000/centos:7

    The push refers to a repository [localhost:5000/centos]

    6e6b57f1d84d: Pushed 

    7: digest: sha256:88dcdb9b54988129d4b63d984236f9b14dcc0c2dd1f77cd33d3673d888c18079 size: 529

    8.运行容器

    docker run -i -t localhost:5000/centos:7 /bin/bash


    root@router:~#docker run -i -t localhost:5000/centos:7 /bin/bash

    [root@ce2171a92f1b /]# uname -a

    Linux ce2171a92f1b 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

    [root@da2ea9c701dc /]# cat /etc/redhat-release 

    CentOS Linux release 7.2.1511 (Core) 

    [root@ce2171a92f1b /]# w

     09:00:17 up  1:41,  0 users,  load average: 0.01, 0.08, 0.12

    USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

    [root@ce2171a92f1b /]# df -h

    Filesystem                                                                                        Size  Used Avail Use% Mounted on

    /dev/mapper/docker-8:1-25168265-1da6fb8109b9cfb53a32d0711bc107264c01ec8303c26cc1d1bf705b60606e4d   10G  481M  9.6G   5% /

    tmpfs                                                                                             5.8G     5.8G   0% /dev

    tmpfs                                                                                             5.8G     5.8G   0% /sys/fs/cgroup

    /dev/sda1                                                                                         8.0G  7.7G  387M  96% /etc/hosts

    shm                                                                                                64M     0   64M   0% /dev/shm


    B.daemon方式Docker Registry 2.0DockerHub加速及私有镜像搭建&RESTAPI

    说明:之前的docker-registry(基于python)已经废止,最新项目转为docker-distribution(基于Go>=1.5)

    WARNING

    Notice: The classical python "Docker Registry" is deprecated, in favor of a new golang implementation. This here is kept for historical purpose, and will not receive any significant work/love any more. You should head to the landing page of the new registry or  the "Distribution" github project instead.

    This repository's main product is the Docker Registry 2.0 implementation for storing and distributing Docker images. It supersedes the docker/docker-registry project with a new API design, focused around security and performance.


    yum安装

    yum -y install docker-distribution

    systemctl enable docker-distribution

    systemctl start docker-distribution


    [root@ct7 ~]# systemctl status docker-distribution

    docker-distribution.service - v2 Registry server for Docker

       Loaded: loaded (/usr/lib/systemd/system/docker-distribution.service; disabled; vendor preset: disabled)

       Active: active (running) since 六 2016-06-11 20:20:58 CST; 2s ago

     Main PID: 2400 (registry)

       Memory: 4.1M

       CGroup: /system.slice/docker-distribution.service

               └─2400 /usr/bin/registry serve /etc/docker-distribution/registry/config.yml


    6月 11 20:20:58 ct7.example.com systemd[1]: Started v2 Registry server for Docker.

    6月 11 20:20:58 ct7.example.com systemd[1]: Starting v2 Registry server for Docker...

    6月 11 20:20:58 ct7.example.com registry[2400]: time="2016-06-11T20:20:58+08:00" level=warning m...

    6月 11 20:20:58 ct7.example.com registry[2400]: time="2016-06-11T20:20:58+08:00" level=info m...wn"

    6月 11 20:20:58 ct7.example.com registry[2400]: time="2016-06-11T20:20:58+08:00" level=info m...wn"

    6月 11 20:20:58 ct7.example.com registry[2400]: time="2016-06-11T20:20:58+08:00" level=info m...wn"

    6月 11 20:20:58 ct7.example.com registry[2400]: time="2016-06-11T20:20:58+08:00" level=info m...wn"

    Hint: Some lines were ellipsized, use -l to show in full.

    [root@ct7 ~]# ps -ef|grep distribution

    root      2400     0 20:20 ?        00:00:00 /usr/bin/registry serve /etc/docker-distribution/registry/config.yml

    root      2407  1890  0 20:21 pts/0    00:00:00 grep --color=auto distribution

    [root@ct7 ~]# netstat -tunlp|grep registry

    tcp6           0 :::5000                 :::*                    LISTEN      2400/registry

    或者

    源码安装

    1.升级go(>=1.5)

    wget http://www.golangtc.com/static/go/1.6.2/go1.6.2.linux-amd64.tar.gz

    tar -xvf go1.6.2.linux-amd64.tar.gz -C /opt

    sudo cat >>/etc/profile <<'HERE'

    export GOROOT=/opt/go

    export GOPATH=/var/tmp/go

    export PATH=$GOROOT/bin:$PATH

    HERE

    source /etc/profile

     

    提示:主要设置GOROOT(安装路径),GOPATH(go项目的存放位置,自定义)

    root@router:~#go version

    go version go1.6.2 linux/amd64

    2.安装docker-distribution

    go get -v github.com/docker/distribution/cmd/registry

    一条命令自动git并编译安装好,这里的版本是2.4.1

    [root@ct7 ~]# $GOPATH/bin/registry -v

    /var/tmp/go/bin/registry github.com/docker/distribution v2.4.1+unknown

    3.启动docker-distribution

    mkdir /var/lib/registry #存放registry的目录一定要存在,否则,在上传image的时候会报503错误

    cd $GOPATH

    ./bin/registry serve .src/github.com/docker/distribution/cmd/registry/config-example.yml 

    看到如下结果,说明docker-distribution成功运行,默认监听在5000端口,配置文件可以根据模板(config-example.yml)来自定义

    最好是放到后台执行

    [root@ct7 go]# pwd

    /var/tmp/go

    [root@ct7 go]# ./bin/registry serve ./src/github.com/docker/distribution/cmd/registry/config-example.yml 

    WARN[0000] No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable.  go.version=go1.6.2 instance.id=9202f4fe-770a-4b6b-b8b5-fd5f39d1bff5 version=v2.4.1+unknown

    INFO[0000] redis not configured                          go.version=go1.6.2 instance.id=9202f4fe-770a-4b6b-b8b5-fd5f39d1bff5 version=v2.4.1+unknown

    INFO[0000] Starting upload purge in 11m0s                go.version=go1.6.2 instance.id=9202f4fe-770a-4b6b-b8b5-fd5f39d1bff5 version=v2.4.1+unknown

    INFO[0000] using inmemory blob descriptor cache          go.version=go1.6.2 instance.id=9202f4fe-770a-4b6b-b8b5-fd5f39d1bff5 version=v2.4.1+unknown

    INFO[0000] listening on [::]:5000                        go.version=go1.6.2 instance.id=9202f4fe-770a-4b6b-b8b5-fd5f39d1bff5 version=v2.4.1+unknown

    [root@ct7 ~]# netstat -tunlp|grep registry

    tcp6           0 :::5000                 :::*                    LISTEN      3190/./bin/registry


    https://docs.docker.com/registry/configuration/#list-of-configuration-options

    配置示例https://github.com/docker/distribution/blob/master/docs/configuration.md#storage

    cat ./src/github.com/docker/distribution/cmd/registry/config-example.yml 

    version: 0.1

    log:

      fields:

        service: registry

    storage:

      cache:

        blobdescriptor: inmemory

      filesystem:

        rootdirectory: /var/lib/registry

    http:

      addr: :5000

      headers:

        X-Content-Type-Options: [nosniff]

    health:

      storagedriver:

        enabled: true

        interval: 10s

        threshold: 3



    REST API

    https://docs.docker.com/registry/spec/api/

    http://docker-py.readthedocs.io/en/latest/api/


    1.查看repo列表

    root@router:~#curl -XGET http://192.168.8.254:5000/v2/_catalog

    {"repositories":["centos","consul","elasticsearch","gliderlabs/registrator","rethinkdb","shipyard/shipyard","swarm","ubuntu","zookeeper"]}

    2.查看repo中的tag列表

    root@router:~#curl -XGET http://192.168.8.254:5000/v2/swarm/tags/list

    {"name":"swarm","tags":["latest"]}

    root@router:~#curl -XGET http://192.168.8.254:5000/v2/consul/tags/list

    {"name":"consul","tags":["0.6.4","latest"]}

    3.删除镜像

    docker官方鉴于v2 版设计的安全性与开发需求成本和磁盘的廉价性,至今没有出和v2类似直接删除并释放磁盘空间的方法,以至于你第三方的shipyard等目前也只支持v1仓库,这里简单介绍一种删除的方法

    i.启用registry删除并重启

    /etc/docker-distribution/registry/config.yml

    version: 0.1 

    log:

      fields:

        service: registry

    storage:

        delete:

            enabled: true

        cache:

            layerinfo: inmemory

        filesystem:

            rootdirectory: /var/lib/libvirt/images/registry

    http: 

        addr: :5000

    systemctl restart docker-distribution

    在storage段启用delete

    ii.查找到对应image的Digest

    Note When deleting a manifest from a registry version 2.3 or later, the following header must be used when HEAD or GET-ing the manifest to obtain the correct digest to delete:

    
    Accept: application/vnd.docker.distribution.manifest.v2+json
    

    注意: 删除时一定要带上v2的Header,否则会删除失败


    root@router:~#curl -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X GET 192.168.8.254:5000/v2/alpine/manifests/latest

    HTTP/1.1 200 OK

    Content-Length: 528

    Content-Type: application/vnd.docker.distribution.manifest.v2+json

    Docker-Content-Digest: sha256:4b8403bacd7f331e2016aaebb92daf955a9b86576c7584e969a9c0f2e4cfa8e7

    Docker-Distribution-Api-Version: registry/2.0

    Etag: "sha256:4b8403bacd7f331e2016aaebb92daf955a9b86576c7584e969a9c0f2e4cfa8e7"

    Date: Fri, 14 Oct 2016 00:16:37 GM

    上面是带了v2头的,下面是没带v2头的,两者的Digest值明显不同,这也是很多同学在删除的时候出现UNKNOWN MANIFEST的错误提示的原因。

    root@router:~#curl -I -X GET 192.168.8.254:5000/v2/alpine/manifests/latest

    HTTP/1.1 200 OK

    Content-Length: 2133

    Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws

    Docker-Content-Digest: sha256:df73ed0973f15f40496c148330f9b559f0a5583c03f6ac8d26adadf6f4690aff

    Docker-Distribution-Api-Version: registry/2.0

    Etag: "sha256:df73ed0973f15f40496c148330f9b559f0a5583c03f6ac8d26adadf6f4690aff"

    Date: Fri, 14 Oct 2016 00:17:41 GMT

    iii.API删除

    root@router:~#curl -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X DELETE 192.168.8.254:5000/v2/alpine/manifests/sha256:4b8403bacd7f331e2016aaebb92daf955a9b86576c7584e969a9c0f2e4cfa8e7

    HTTP/1.1 202 Accepted

    Docker-Distribution-Api-Version: registry/2.0

    Date: Fri, 14 Oct 2016 00:24:06 GMT

    Content-Length: 0

    Content-Type: text/plain; charset=utf-8

    iv.垃圾回收

    root@router:~#registry garbage-collect /etc/docker-distribution/registry/config.yml

    INFO[0000] Deleting blob: /docker/registry/v2/blobs/sha256/4b/4b8403bacd7f331e2016aaebb92daf955a9b86576c7584e969a9c0f2e4cfa8e7  go.version=go1.4.2 instance.id=51bf4ba4-6e9c-4851-a684-da75ed8615d1

    INFO[0000] Deleting blob: /docker/registry/v2/blobs/sha256/c0/c0cb142e43453ebb1f82b905aa472e6e66017efd43872135bc5372e4fac04031  go.version=go1.4.2 instance.id=51bf4ba4-6e9c-4851-a684-da75ed8615d1

    INFO[0000] Deleting blob: /docker/registry/v2/blobs/sha256/ee/ee4603260daafe1a8c2f3b78fd760922918ab2441cbb2853ed5c439e59c52f96  go.version=go1.4.2 instance.id=51bf4ba4-6e9c-4851-a684-da75ed8615d1

    DockerHub加速及私有镜像搭建&RESTAPI

    python脚本 https://github.com/liujun1990/python/blob/master/available/dockerRegistryV2.py



    A list of methods and URIs are covered in the table below:

    Method Path Entity Description
    GET /v2/ Base Check that the endpoint implements Docker Registry API V2.
    GET /v2//tags/list Tags Fetch the tags under the repository identified by name.
    GET /v2//manifests/ Manifest Fetch the manifest identified by name and referencewhere referencecan be a tag or digest. A HEADrequest can also be issued to this endpoint to obtain resource information without receiving all data.
    PUT /v2//manifests/ Manifest Put the manifest identified by name and referencewhere referencecan be a tag or digest.
    DELETE /v2//manifests/ Manifest Delete the manifest identified by name and reference. Note that a manifest can onlybe deleted by digest.
    GET /v2//blobs/ Blob Retrieve the blob from the registry identified by digest. A HEAD request can also be issued to this endpoint to obtain resource information without receiving all data.
    DELETE /v2//blobs/ Blob Delete the blob identified by name and digest
    POST /v2//blobs/uploads/ Initiate Blob Upload Initiate a resumable blob upload. If successful, an upload location will be provided to complete the upload. Optionally, if the digestparameter is present, the request body will be used to complete the upload in a single request.
    GET /v2//blobs/uploads/ Blob Upload Retrieve status of upload identified by uuid. The primary purpose of this endpoint is to resolve the current status of a resumable upload.
    PATCH /v2//blobs/uploads/ Blob Upload Upload a chunk of data for the specified upload.
    PUT /v2//blobs/uploads/ Blob Upload Complete the upload specified by uuid, optionally appending the body as the final chunk.
    DELETE /v2//blobs/uploads/ Blob Upload Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout.
    GET /v2/_catalog Catalog Retrieve a sorted, json list of repositories available in the registry.



    Registry V2 UI

    docker run --name registry-browser -it -p 8080:8080 -e DOCKER_REGISTRY_URL=http://localhost:5000 klausmeyer/docker-registry-browser
  • 相关阅读:
    JSP第六次作业
    JSP第五次作业
    第二次软件测试作业
    JSP第四次作业(2)
    JSP第四次作业(1)
    JSP第七次作业
    JSP第六次作业
    session对象练习
    JSP第四次作业(2)
    JSP第四次作业(1)
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814057.html
Copyright © 2011-2022 走看看