How Can I Whitelist Specific Docker Images on ghcr.io for Developers?

May 1, 2025 5 answers
Asked by ~cloud cover+
Hi everyone! I'm part of an IT Security team and I'm looking to give our developers the ability to pull certain images from ghcr.io without granting them access to all images available there. Ideally, I want to set up a whitelist rule, like "ghcr.io/tektoncd/pipeline/*", which would allow them to run commands like "docker pull ghcr.io/tektoncd/pipeline/entrypoint-bff0a22da108bc2f16c818c97641a296:v1.0.0". However, if they attempt to pull something that's not on the whitelist, such as images from "ghcr.io/fluxcd/source-controller:sha256-9d15c1dec4849a7faff64952dcc2592ef39491c911dc91eeb297efdbd78691e3.sig", the command should fail. I'm open to any toolsโ€”whether free or paidโ€”that could help with this setup. Any suggestions?

Answers

notebook_margin
We actually self-host Harbor and use its webhook to rewrite image registries to point to Harbor. Plus, we leverage Kyverno to manage the image pull secrets effectively.
Reply to this answer
where was I
One way to manage this is by using a private registry with mirror rules set up for ghcr.io. This way, you can control which images are pulled based on your whitelist.
Reply to this answer
splice-1site
Iโ€™d suggest checking out the ValidatingAdmissionWebhook feature in Kubernetes. You can use a tool like Kyverno to enforce your image policies. For example, you could set a policy that only allows images from ghcr.io, ensuring that anything else gets blocked. Here's a quick sample policy to illustrate:

_ask_for_details: Wow, this looks super helpful! Thanks for sharing.

Reply to this answer
first chair clarinet
If you want a native solution within Kubernetes, the admission policy feature might be what you need. There's no necessity for third-party tools if you follow this route.
Reply to this answer
Larkspur
For a more robust solution, consider combining Kyverno or Gatekeeper with a private registry like Harbor. This will give you the flexibility you need.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions