Skip to content

✨ Provision to define private docker registry at global level #2238

Closed

Description

@nipuna-perera

What are you trying to do?

Use a private docker registry instead of docker hub for all images.

Why is this important to you?

We have a corporate Artifactory implementation which proxies all docker images through a private registry. like

myregistry.company.com/alpine:3

which actually proxies the image via docker hub.

Currently, universe packages such as Alpine and Nginx uses hardcoded docker hub registry like

docker.#Pull & {
	source: "index.docker.io/alpine:\(version)"
}

Dagger should standardize the way "image source" is defined for packages. I like the way it is an input in the Go package but it would be nice to be able to specify a private registry at a global level.

How are you currently working around this?

I have to pull the image with #Docker.pull and specify the auth and source to pull images via my private registry because I can't use #Alpine out of the box.

Activity

  1. grouville commented on Jul 13, 2022

    @grouville
    Member

    @mircubed @helderco @shykes @jpadams. This issue got encountered again today by the user @calvinxu.

    He is still stuck (I showed him an alternative, a solution, but he cannot onboard on the todoApp example as it's too complex to modify everything to make it work for an onboarding start). He was trying out Dagger with the todoApp example:

    • Working from his company, he was getting the docker hub pull rate limit issue. As the example doesn't permit to easily login, he's basically stuck

    It shows a more in-depth issue:

    • Most of the packages (alpine, netlify, yarn) don't allow to easily add/modify a registry url, and auth credentials, which are often client infos

    2 solutions:

    • design another todoApp, and change most of the universe packages to include that option
    • Find a system to allow global env var ? It would however break the all host interactions happen in the client API
    • Find an alternative (?)
  2. helderco commented on Jul 13, 2022

    @helderco
    Contributor

    It would however break the all host interactions happen in the client API

    Not at all. It wouldn't be a var available to a CUE action, so it doesn't break client API. It would be something that Go reads during execution of core.#Pull to fill in the auth if needed.

  3. grouville commented on Jul 13, 2022

    @grouville
    Member

    Oh ok. I see your point of view. I can assign this issue to myself and make a PR to solve it, with this solution. Would you be ok @helderco ?

  4. shykes commented on Jul 13, 2022

    @shykes
    Contributor

    I have two problems with this:

    • There's no guarantee that alpine relies on pulling an image from docker hub, or any registry at all. In the future it could for example assemble an image from alpine packages by talking to alpine registries directly. Or it could pull from a third-party image registry, unrelated to docker hub.

    • If we implement a "side-load" to authenticate core.#Pull globally, that has pretty major implications, for example:

      • Why stop at docker registries? Will we not need to do the same for any action that a) may require authentication, and b) may be wrapped by a higher-level action that does not allow explicit auth override?
      • What will be the behavior, exactly? Will it be an override, or a default?

    I'm still in favor of doing it, but in doubt we should assume it's a short-term stopgap and it may have longer-term design issues. But still think it's worth doing it to alleviate user pain.

  5. helderco commented on Jul 13, 2022

    @helderco
    Contributor

    The way I suggested it was just to have two settings (e.g., DOCKERHUB_AUTH_USER, DOCKERHUB_AUTH_PASS) to apply in Go if they exist and the image to pull matches the index.docker.io registry, and has no auth.

    Since universe actions pull a lot of images from the docker hub, it's very hard to override every image just to add authentication due to the rate limit.

    So the scope can be very limited to just docker hub. I don't see any implications coming from this. If you're using some other registry or set of images with universe actions, you're already overriding them and you should already have your own personal/company abstraction for it. At least the most common case of hitting rate limits against the public registry gets a bit better.

    If you're pulling alpine through some other means (i.e., not via the docker hub), then this wouldn't apply.

    • docker.#Pull & { source: "alpine" } ✅
    • docker.#Pull & { source: "registry.gitlab.com/alpine/alpine" } ❌
    • docker.#Pull & { source: "alpine", auth: _auth } ❌

    With #Dockerfile and #Push it's different because they're not burried in universe actions. You control those so you can provide an auth. Still, if you have a global auth for docker hub, users may expect them there as well.

    I do agree that this is a stopgap. We need a better abstraction because people need generalized auth, mirrors/proxies, etc... in their environments. This is like asking for an equivalent of docker login before doing docker build.

  6. shykes commented on Jul 13, 2022

    @shykes
    Contributor

    Sounds good, I don't have anything better to suggest anyway, and doing nothing is not an option... 👍

  7. helderco commented on Jul 13, 2022

    @helderco
    Contributor

    There's two issues here.

    @grouville put the other one here (#2238 (comment)) to fix the case of exceeded rate limiting for the docker hub, but that's different from what the OP's asking:

    • Provide global setting to change the default registry globally (this issue... has more implications)
    • Provide global setting with auth for the docker hub registry (should be a different issue)

    As for changing the registry like OP's asking, if it's a mirror I think it's ok, but it also opens the door for potentially returning different images from what dagger's expecting (depending on the registry), leading to unexpected behavior and confusion. It has more implications and it's a use case for that better abstraction that we need, but I'm not so sure of doing the same thing as with auth for now.

  8. shykes commented on Jul 19, 2022

    @shykes
    Contributor

    For the record, another short-term fix that might be better: move away from Docker Hub for default images in universe. Either by moving to a more generous image hosting provider that doesn't mind acting as a free CDN; or building images in such a way that a base image doesn't need to be downloaded again (build from distro packages a-la apko, or even from source). As discussed with @jpadams who will create an issue.

    (We should still implement this stopgap. Just noting that we may be able to get rid of it later)

  9. TomChv commented on Oct 30, 2023

    @TomChv
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions