Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for using the local k3d registry as a proxy for the Docker Hub #207

Merged
merged 1 commit into from
Mar 13, 2020

Conversation

inercia
Copy link
Collaborator

@inercia inercia commented Mar 13, 2020

With this option, the local k3d registry can act as a pull-through cache for the Docker hub.

For example, after creating the cluster with:

k3d create --enable-registry --enable-registry-cache --registry-volume=k3d-registry

we can see that the registry is caching the images:

$ docker exec -ti k3d-registry ls -lisa /var/lib/registry/docker/registry/v2/repositories/library /var/lib/registry/docker/registry/v2/repositories/rancher
/var/lib/registry/docker/registry/v2/repositories/library:
total 16
42206594      4 drwxr-xr-x    4 root     root          4096 Mar 13 09:52 .
33554483      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 ..
42860646      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 busybox
42206595      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 traefik

/var/lib/registry/docker/registry/v2/repositories/rancher:
total 28
33554484      4 drwxr-xr-x    7 root     root          4096 Mar 13 09:52 .
33554483      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 ..
33554829      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 klipper-helm
33554475      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 klipper-lb
33554819      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 local-path-provisioner
33554850      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 metrics-server
33554485      4 drwxr-xr-x    5 root     root          4096 Mar 13 09:52 pause

Signed-off-by: Alvaro Saurin <alvaro.saurin@gmail.com>
Copy link
Member

@iwilltry42 iwilltry42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Very cool feature, thank you!

@iwilltry42 iwilltry42 merged commit 9048c75 into k3d-io:master Mar 13, 2020
@inercia inercia deleted the inercia/registry-cache branch March 15, 2020 13:14
@deiwin
Copy link

deiwin commented Apr 21, 2020

This cannot be used together with pushing local images to the registry. See https://stackoverflow.com/a/33616926/1456578 and https://docs.docker.com/registry/configuration/#proxy.

Pushing to a registry configured as a pull through cache is currently unsupported

One would just get unsupported as a response when trying to push to the registry.

Maybe the cache should be configured as a separate registry if enabled?

@iwilltry42
Copy link
Member

Thanks for the hint @deiwin 👍
For now, we added documentation/hints regarding this (commit).

I agree that it makes sense to split this up into two separate registry containers in the future 👍

@svenhofstede-zz
Copy link

Does this only work for images pulled from Docker hub or also for images pull from private repositories?

@iwilltry42
Copy link
Member

iwilltry42 commented Apr 24, 2020

@svenhofstede with the mirrors statement in the registries.yaml you can redirect pulls for every registry to a different registry. So yes, the concept should as well work for any other registry, but this PR/flag only sets it up for DockerHub.
You can edit the file manually: https://github.com/rancher/k3d/blob/master/docs/registries.md#registries-file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants