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:
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"
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
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
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"}}]}
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 .
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With