docker pull over cache for private registry not working

dos*_*oss 5 docker docker-registry

我尝试使用docker 1.8在注册表2.1.1版本中发布的pull through缓存docker.在CentOS7.1上但是,我遵循这些网站,并没有充当镜像,任何输入将非常感激.我希望这是配置注册表服务和传递docker守护程序参数的正确方法.

网站:https : //github.com/docker/distribution/blob/master/docs/mirror.md http://docs.master.dockerproject.org/articles/registry_mirror/

脚步:

  1. 我添加了参数以传递给docker守护进程并重新启动它:

    # /etc/sysconfig/docker 
    # 
    # Other arguments to pass to the docker daemon process 
    # These will be parsed by the sysv initscript and appended 
    # to the arguments list passed to docker -d
    OPTIONS="--registry-mirror=http://localhost:5000" 
    
    Run Code Online (Sandbox Code Playgroud)
  2. 添加了注册表配置并挂载到容器:

    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
    proxy:
      remoteurl: https://registry-1.docker.io
    
    Run Code Online (Sandbox Code Playgroud)
  3. 启动注册表容器

    docker run -d -p 5000:5000 --restart=always --name registry-mirror -v /opt/docker-registry/local/images:/var/lib/registry -v /opt/docker-registry/local/config/config.yml:/etc/docker/registry/config.yml -e STANDALONE=false -e MIRROR_SOURCE=https://registry-1.docker.io -e MIRROR_SOURCE_INDEX=https://index.docker.io registry:2.1.1
    
    Run Code Online (Sandbox Code Playgroud)
  4. 使用以下命令测试pull through缓存:

    我的镜子运行后,拉出我之前没有拉过的图像(使用时间)

    从配置为MIRROR_SOURCE的docker hub拉出

    $ time docker pull busybox:latest
    
    Run Code Online (Sandbox Code Playgroud)

    从本地计算机中删除图像

    $ docker rmi busybox:latest
    
    Run Code Online (Sandbox Code Playgroud)

    最后,这应该从缓存重新拉出图像,这在我的情况下不起作用,而是从docker hub取而代之.

    $ time docker pull busybox:latest
    
    Run Code Online (Sandbox Code Playgroud)

    我也尝试查看我的主机文件系统中挂载的图像卷文件夹,找不到它.

    $ ls /opt/docker-registry/local/images/docker/registry/v2/repositories/
    
    Run Code Online (Sandbox Code Playgroud)

    尝试对该新图像进行rest api调用,而是返回错误消息:

    $ curl http://localhost:5000/v2/busybox/tags/list     
        {"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry","detail":{"name":"busybox"}}]}
    
    Run Code Online (Sandbox Code Playgroud)

小智 2

它对我有用...

docker run -p 5000:5000 \
    -e STANDALONE=false \
    -e MIRROR_SOURCE=https://registry-1.docker.io \
    -e MIRROR_SOURCE_INDEX=https://index.docker.io \
    -e "REGISTRY_LOG_LEVEL=debug" \
    -e "REGISTRY_REDIRECT_DISABLE=true" \
    -v /var/lib/registry:/var/lib/registry \
    --name registry-cache-latest \
    registry
Run Code Online (Sandbox Code Playgroud)

..然后将 --registry-mirror 指向 http 服务器,而不是 https。