Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker pull through cache for private registry not working

I tried the pull through cache docker released in registry 2.1.1 release with docker 1.8. on CentOS7.1 However, I followed these websites and it doesn't act as mirroring, any inputs would be much appreciated. I hope this is the right way of configuring registry service and passing docker daemon arguments.

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

Steps:

  1. I added arguments to pass to docker daemon process and restarted it:

    # /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" 
    
  2. Added registry config and mounted to the container:

    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
    
  3. Launched registry container

    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
    
  4. Tested pull through cache with commands as follows:

    With my mirror running, pull an image that I haven't pulled before (using time to time it)

    Pulls from docker hub as configured as MIRROR_SOURCE

    $ time docker pull busybox:latest
    

    Remove the image from local machine

    $ docker rmi busybox:latest
    

    Finally, this should re-pull the image from cache, which is not working in my case, rather pulling from docker hub instead.

    $ time docker pull busybox:latest
    

    I also tried looking at the mounted images volume folder in my host file system, couldn't find it.

    $ ls /opt/docker-registry/local/images/docker/registry/v2/repositories/
    

    Tried making rest api call to that new image, returns error message instead:

    $ curl http://localhost:5000/v2/busybox/tags/list     
        {"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry","detail":{"name":"busybox"}}]}
    
like image 224
doss Avatar asked Sep 11 '15 19:09

doss


People also ask

How do I pull a private image in Docker?

In order to pull images from your private repository, you'll need to login to Docker. If no registry URI is specified, Docker will assume you intend to use or log out from Docker Hub. Triton comes with several images built-in. You can view the available list with triton images .

Does Docker pull use cache?

Pulling cached imagesThe Docker daemon checks the Container Registry cache and fetches the images if it exists. If your daemon configuration includes other Docker mirrors, the daemon checks each one in order for a cached copy of the image.

What is private Docker registry FQDN?

A private Docker registry allows you to share your custom base images within your organization, keeping a consistent, private, and centralized source of truth for the building blocks of your architecture.


1 Answers

It worked for me using ...

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

.. and then pointintg --registry-mirror to the http server, not https.

like image 157
Jose Tavares Avatar answered Oct 15 '22 06:10

Jose Tavares