-
Notifications
You must be signed in to change notification settings - Fork 71
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
Default to docker.io #423
Comments
I will have to dig deeper into Containerd image pulling logic and Kubernetes sends image references through the CRI API. While Docker does implicitly assume that the registry is docker.io that is not the case for Containerd. When pulling with ctr for example it requires you to give a full image reference including the registry. The interesting thing that is happening here is that Containerd is picking up the registry in the mirror configuration, but is not adding the original registry in the mirrored HTTP request. While defaulting would solve this specific problem, I think that we need to understand the core issue of why this is occurring. |
Thank you very much for the very quick response! Ah ok, you're right. Which might also be interesting (maybe that's what you mean by "Containerd is picking up the registry in the mirror configuration"): The download still works, even though I specified Spegel as the mirror only. Unfortunately, I'm not sure whether Docker simply sends a request to docker.io anyway if Spegel responds with a 404? In any case, the images are available at the end. |
I just ran the e2e tests without the registry specified and it worked without any issues so we need to dig a bit deeper into this. To make sure that we are on the same page. Am I right to assume that you are running Spegel in Kubernetes and specifying the image references in a Pod spec? Or are you using Spegel in some other fashion. The reason I ask is that there is a difference between how Containerd will pull an image and how Docker would, which is critical for the functionality of Spegel. Could you just quickly describe your environment so that I can better understand where the error originates from. |
Yes sure:
Values spegel:
containerdRegistryConfigPath: /etc/cri/conf.d/hosts
serviceMonitor:
enabled: true All Pods are automatically pulling their images successfully. So it's basically working as expected. I want to use it in gha-runner-scale-set: - image: docker:26.0.0-dind
name: dind
securityContext:
privileged: true
env:
- name: DOCKER_GROUP_GID
value: "123"
args:
- dockerd
- --host=unix:///var/run/docker.sock
- --group=$(DOCKER_GROUP_GID)
- --registry-mirror=http://spegel-registry.spegel.svc.cluster.8log.de.local:5000
volumeMounts:
- mountPath: /home/runner/_work
name: work
- mountPath: /var/run
name: dind-sock
- mountPath: /home/runner/externals
name: dind-externals
Do you need further information? |
I had a feeling the problem would come from DIND, i was expecting some issue like this as you stated you were using this in a CI. First of all the issue isn't huge but still something you want to fix. The error you are seeing comes from when Docker tries to resolve the image tag to a digest. Which Spegel will fail to do with you setup for all images. Thankfully Docker and in turn Containerd will always fallback to the original registry if the mirror fails. This is a very nice feature to have. The reason Spegel is not able to resolve the tag is because it requires the original registry to be included in the request. This additional data is not required when fetching other layers as they are referenced by their digest. The registry is expected to be passed as a query parameter in the HEAD request.
Now sadly this is not yet part of the OCI distribution spec yet as it is pending reviews. Containerd however has already implemented the feature a long time ago. So Spegel relies on the fact that Containerd is pulling the image. Containerd forked parts of Dockers code to pull images a while back so this change never mades its way into the Docker codebase. Finally to the two solutions you have. You can either disable tag resolving in Spegel, which isn't great but would remove the errors. Or you configure Docker to use Containerd as it's image store. When enabled Docker will depend on Containerd to run as your image store. This means that Containerd will be pulling images for you. https://docs.docker.com/storage/containerd/#enable-containerd-image-store-on-docker-engine Having said that I am aware that this means that images pulled by Docker would end up in its own Containerd namespace which will not be shared by Kubernetes so Spegel will not pick this up. We could solve this pretty easily by allowing users to configure multiple Containerd namespaces. I have been thinking about writing some best practice docs for using Spegel with build systems as I know that there are some interesting aspects around build layer caching between nodes. It is not something that I have started to work on sadly. Hopefully this answers your questions, I will have a look in allowing multiple namespaces if Docker uses a different namespace. |
Thank you very much for this detailed explanation! I have learned a lot just by reading it. I'm not that deep into this topic, so I didn't realize that it behaves so differently. I would be very happy about best practices for using Spegel with build systems. This is exactly the area I would like to optimize. Currently, all images are downloaded again in every CI run. This is such an unnecessary waste of resources.
As this only causes the error messages to disappear, this is not an option.
That would mean that the images can really be delivered by spegel? That would be completely sufficient for me for now. My approach would otherwise be to set up a local docker registry as a cache through proxy and connect dind to it. Anyway. Thanks again for the quick and detailed help and the great tool. When I discovered Spegel, I was immediately impressed. It was exactly what I was looking for. |
No problem. I tested this setup myself and observed that Docker will create a separate namespace called Reading Containerd docs however states that by default blobs will be shared between namespaces. So it might not be as bad as I expected. https://github.com/containerd/containerd/blob/main/docs/ops.md#bolt-metadata-plugin I will verify that this also includes image metadata later today. If that is true we can basically assume that namespaces are a non issue and the content will be shared between the two namespaces. |
Chipping in to say I'm also interested in this workflow - already using/abusing an environment variable flag to enable containerd backend in my DIND github actions runner sets, so half the way there. |
@phillebaba can i help you with this topic in any way? |
@mrclrchtr Did you get it working, at least pulling somethings? I get the feeling GitHub actions docker pulls (like ghcr.io/renovatebot/renovate) still dont get into my Spegel using this:
|
Unfortunately not. I still use docker registries as a pull through cache. |
I fixed it by moving to the kubernetes backend. However, Kubernetes backend worked like an absolute charm. |
@PrivatePuffin what do you mean by kubernetes backend? I googled it briefly, but couldn't find anything useful. |
GitHub Actions Controller has both a kubernets or DinD deployment option. |
Describe the problem to be solved
Hi, I would like to use spegel as a pull through cache in my pipeline. There images are often specified as follows:
Spegel then says the following error message:
Proposed solution to the problem
My understanding is that there is always implicitly "docker.io" as registry in front of this notation or? Would it be possible to set this default instead of throwing the error message? Or at least offer the option to set a default?
The text was updated successfully, but these errors were encountered: