Skip to content

Support client-side registry configuration of CA+Mirrors #4217

Closed

Description

@sipsma

Background

Users often need CA certs or mirror configuration in order to push/pull container images.

Right now, the only way to accomplish that is to customize the engine image and install those certs in the right directory + setup a configuration file for mirrors. This is often extremely inconvenient.

In many cases the user has the required CA certs locally or has access to the correct mirror configuration. They just need a way to tell our engine to use them.

It thus makes sense to allow this to be configured by clients and then passed to the engine server rather than forcing it to be a part of engine setup prereqs.

Related:

Options

A) Part of Core API

We can put this explicitly in the core API.

Pros:

  1. Each SDK picks it up for free via codegen. Only the CLI has to have any actual implementation. It's thus also available to raw graphql clients too.
  2. Centralizing configuration in our schema as much as possible keeps things more consistent for users
  3. Gives lots of flexibility to users (settings can be per request) but there's also opportunities to keep boilerplate low (see proposal below)
  4. Interesting possible integration points with extensions (see proposal below)

Cons:

  1. Doesn't inherently encode a "standard way" of picking up config from the environment, which may be what users actually want most often.
    • You could implement this (i.e. you could read serialized settings from a file on the host an then include that in your queries), but it would not be "standardized"
    • Queries thus become more specific to individual clients (already true due to the existence of the host api, but this takes us further down that road)

Strawman schema proposal

Fine grained API:

input RegistryConfig {
   // each string is the actual contents of the rootCA cert, not a path to it
   RootCAs: [String!]
   // a list of mirrors to use for the provided address
   Mirrors: [String!]
}

type Container {
 from(address: String!, registryConfig RegistryConfig): Container!
 ...
 publish(address: String!, platformVariants: [ContainerID!], registryConfig RegistryConfig): String!
}

The fine grained approach would give the ultimate flexibility at the cost of boilerplate.

Easier to use might be a "wrapper" API (though not mutually exclusive with above):

extend type Query {
  withDefaultRegistryConfig(registryHost: String!, registryConfig: RegistryConfig!) Query!
}

withDefaultRegistryConfig could be very interesting in combination with extensions; you could imagine a company that wants to enforce use of certain ca+mirror configuration vends out an extension that users call to pick up all the necessary configs.

B) Part of CLI Configuration

We could make these settings something you configure via the CLI. They would then get persisted to a file under ~/.config/dagger/ or something. When you use dagger run or an SDK uses dagger session they would get picked up automatically

Pros:

  1. The code written by users in SDKs is detached from these settings. You can run the same SDK code with different CA+Mirror settings without changing the code necessarily

Cons:

  1. Less flexible, essentially operates as unchangeable global state.
  2. The CA and mirror config must exist as strings persisted in the local filesystem
    • Misses out on possible compelling use cases where, e.g., the settings get configured by an extension

Preferred Option

After writing this out I'm realizing these options are actually not contradictory at all. In fact if they both existed they might complement one another pretty nicely. Many possibilities but you could imagine that:

  1. The CLI allows you configure defaults for registry config, which would actually map in the implementation to all queries just being wrapped in withDefaultRegistryConfig
    • I think there's a ton of possibilities for re-using this pattern elsewhere outside these registry settings (cache config, networking, etc.)
  2. Additionally, users who prefer being explicit in their code (or really need per-query settings rather than global ones) can also use the explicit API in their queries

So, I actually think we should consider doing both options in the fullness of time. Proposal for an order of operations:

  1. Add support for configuring these settings in the CLI only
  2. In the future when more compelling use cases like the one mentioned involving extensions arise, also add withDefaultRegistryConfig to the core api schema that exposes the same config settings
  3. If ever needed, can also add support for individual registry config settings in Container.from and Container.publish (though I think use cases that call for that might be obscure)

Implementation

Implementation-wise, I think we should strive for something that is not specific to any one provisioner target. That means it would be best avoid reliance on e.g. docker bind mounts since that requires dagger to be running in docker (and the daemon to be local).

I think the best approach would be the upstream change suggested here: moby/buildkit#3366

That would just let us re-use the existing interface between CLI<->Runner.

A fallback would be creating our own separate channel/API between CLI<->Runner (free to do now since we control the engine image). But that's probably not worth it unless we run into problems upstreaming it.

Activity

  1. added
    area/engine
    on Dec 17, 2022
  2. dergyitheron commented on Jan 30, 2023

    @dergyitheron

    Hi guys,

    it's been kinda quiet here so I wanted to ask what's the status of this issue?

    I've created this post couple of months back and it looked like it started some discussions leading to this issue. The workaround mentioned in the post didn't work for me. And although it's not crucial to have this, at the same time it's the only thing blocking me for using dagger at work.

    So I'm just curious if there are any updates regarding configuration of self signed CA for registries?

    Thanks.

    David

  3. frantjc commented on Aug 24, 2023

    @frantjc
    Contributor

    For anyone actively struggling with this, I found a workaround that I quite like when using a dagger SDK (Nodejs in my case). It effectively just uses the docker CLI to modify the certificates of the dagger engine container after the SDK spawns it, so should be easily portable to the language of your choice:

    import { connect } from "@dagger.io/dagger";
    import cp from "child_process";
    
    connect(async (client) => {
      // Copy your certificate into the Dagger engine container.
      const daggerEngineContainerId = cp.execSync("docker ps -qf name=dagger-engine").toString().trim();
      cp.execSync(`docker cp my-root-ca-path.pem ${daggerEngineContainerId}:/etc/ssl/certs/ca-certificates.crt`);
      
      // Go about your Dagger business!
      client.container().from("my.self.signed.regsitry/repository:tag");
    });
  4. nipuna-perera commented on Oct 3, 2023

    @nipuna-perera
    Contributor

    I would like to bump this issue as it's becoming increasingly important to us too. We don't want to maintain a custom version of the dagger engine.

  5. benkeil commented on Jan 21, 2025

    @benkeil

    For us it's also kind of a blocker. I can't convince my team that everyone needs to take care of setting up a custom dagger engine with ca-certificates.

  6. jedevc commented on Jan 21, 2025

    @jedevc
    Contributor

    Ah @benkeil thanks for reviving this! This is an older issue (that I wasn't actually aware of), there's been a lot more discussion around this in #9007.

    Couple points on @sipsma's original proposal:

    • I think we're gonna have a few different session config methods - so having a SessionConfig type might be nice to group them under, instead of attaching them all at the top-level.
    • A lot of the architecture has changed in the last year, especially around our interactions with buildkit - this opens a lot of interesting doors.
  7. jedevc commented on Aug 29, 2025

    @jedevc
    Contributor

    Gonna propose something to move this forward: we should just have a ~/.config/dagger/ca-certificates folder (next to ~/.config/dagger/engine.json).

    That way we can actually avoid the separate configuration of https://docs.dagger.io/reference/configuration/engine/#custom-certificate-authorities:

    Image

    Long term, having API changes definitely makes sense, but, it feels important to have a option in the short term.

  8. marcosnils commented on Sep 9, 2025

    @marcosnils
    Contributor

    Gonna propose something to move this forward: we should just have a ~/.config/dagger/ca-certificates folder (next to ~/.config/dagger/engine.json).

    I was actually thinking the exact same idea. @jedevc do you see a first possible implementation to only change the engine providers so they mount this directory in the engine and that's it? Is there anything else you think we should be doing besides that?

  9. jedevc commented on Sep 9, 2025

    @jedevc
    Contributor

    Yup, that's pretty much what I was thinking.

    The logic to do that pretty much already exists for mounting the engine config in - so we just need to replicate that.

  10. MikaelElkiaer commented on Sep 10, 2025

    @MikaelElkiaer

    Would it also work with symlinked certs?

  11. jedevc commented on Sep 10, 2025

    @jedevc
    Contributor

    Probably with a bit of extra work, that could work? Probably need to modify the mechanism they end up in the engine then.

  12. nipuna-perera commented on Sep 10, 2025

    @nipuna-perera
    Contributor

    Gonna propose something to move this forward: we should just have a ~/.config/dagger/ca-certificates folder (next to ~/.config/dagger/engine.json).

    That way we can actually avoid the separate configuration of https://docs.dagger.io/reference/configuration/engine/#custom-certificate-authorities:

    Image Long term, having API changes definitely makes sense, but, it feels important to have _a_ option in the short term.

    Link: #11019

    As a enterprise user that has to point a bunch of CLI tools for CA Certs, this gets very tedious. I like that there is a way to do this and this potentially gets me out of maintaining a custom engine image (proxies being the last one standing after this). But, would it be possible to use one of the known/standard env vars that point to certs and pull that in? For example, I've configured these in my env

    NODE_EXTRA_CA_CERTS
    SSL_CERT_DIR
    SSL_CERT_FILE
    CURL_CA_BUNDLE
    REQUESTS_CA_BUNDLE
    

    I'm wary of asking Devs to add another one for DAGGER (I know, I'm doing that right now with _EXPERIMENTAL_DAGGER_RUNNER_HOST).

  13. shykes commented on Sep 12, 2025

    @shykes
    Contributor

    Summarizing my discord discussion with @matipan just now:

    • Client-side configuration is the way to go. For example, feat: mount client ~/.config/dagger/ca-certificates to engine #11019 is the perfect UX: add certificates locally to ~/.config/dagger/ca-certificates and boom, it just works
    • However, CA certificates and registry mirrors should not be engine-wide configuration (locally configured or otherwise). They should be session configuration, queried by the engine via session attachables.
    • This removes the complexity and brittleness of having to keep local engine configuration in sync with engine provisioning. It's also more consistent with other client-side configuration that is already implemented: docker auth, git auth, dagger cloud auth... These are all session configuration, and that's a good thing.

    FYI @jedevc @marcosnils @kpenfound

  14. shykes commented on Sep 12, 2025

    @shykes
    Contributor

    @matipan in the case of registry config, I'm wondering if we should:

    1. merge your upcoming PR which uses engine.json, knowing that we will need to break the UX later when we make this a session-specific config
    2. merge your PR but change the config to use the other config file (I forget the path). Even though it's implemented as an engine-wide config now, we would quickly follow-up to change that - this allows us to do so without breaking the UX later
    3. scrap your PR, and open a new one which implements the session attachable from the start
  15. marcosnils commented on Sep 13, 2025

    @marcosnils
    Contributor
    • However, CA certificates and registry mirrors should not be engine-wide configuration (locally configured or otherwise). They should be session configuration, queried by the engine via session attachables.
    • This removes the complexity and brittleness of having to keep local engine configuration in sync with engine provisioning. It's also more consistent with other client-side configuration that is already implemented: docker auth, git auth, dagger cloud auth... These are all session configuration, and that's a good thing.

    I think we all agree with this.

    IIUC and in my opinion shipping #11019 is worth as a quick solution to the problematic of requiring wrapper scripts to start the engine. At the same time, I don't think I ever saw someone requesting the ability to provide this at the session level for multi-tenancy reasons. Again, I'm not saying we shouldn't do it but given that all the current CA provisioning logic works at the engine global level, it sounds reasonable that #11019 also follows the same approach given that the change is minor.

    @matipan in the case of registry config, I'm wondering if we should:

    1. merge your upcoming PR which uses engine.json, knowing that we will need to break the UX later when we make this a session-specific config
    2. merge your PR but change the config to use the other config file (I forget the path). Even though it's implemented as an engine-wide config now, we would quickly follow-up to change that - this allows us to do so without breaking the UX later
    3. scrap your PR, and open a new one which implements the session attachable from the start

    Re-posting parts of what I shared in Discord:

    I think there's an important component that we're not factoring in this conversation which is "where this config lives". In the "session attachable" case, everything lives in the client's context; the docker.json, .gitconfig, etc. In many cases like registry proxy configs, CA certificates and registry credentials, it results convenient to have them on the engine side so that way they're only set once for all clients.

    We actually ran into this exact limitation this week while working in some specific feature which required the registry auth credentials to live in the engine config and we don't have a way to configure this ATM. The reason for this is because we were spawning the engine in an environment which already had some pre-configured env variables with some credentials that the engine requires to be able to publish images to a specific registry (think about AWS instance profiles for instance). The client which was connecting to such engine was running in a different environment where these credentials couldn't be accessed for compliance reasons.

    In any case, it seems to me that the final solution looks something that allows configuring things either globally or per-session depending on the user preference.

  16. shykes commented on Sep 13, 2025

    @shykes
    Contributor

    in my opinion shipping #11019 is worth as a quick solution to the problematic of requiring wrapper scripts to start the engine.

    Yez, agreed. Especially since the UX does not lock us into one implementation or the other.

    I don't think I ever saw someone requesting the ability to provide this at the session level for multi-tenancy reasons.

    I don't though it's a matter of a specific feature request, but of overall system design. Any configuration that affects the execution context should be granular enough to apply to individual client sessions. And I agree that it would also be convenient to have a way to apply it to several sessions and even globally to all sessions of an engine - and perhaps in the future across multiple engines. But regardless of which sessions it is applied to, it should be a unified config system and the implementation should be consistent. In other words, we shouldn't decide in advance which parts of the execution context are only configurable on the client, and which are only configurable globally.

    Also, even when configuring it globally it shouldn't require provisioning a new engine, because that adds a lot more complexity for operators that is not necessary.

    Again, I'm not saying we shouldn't do it but given that all the current CA provisioning logic works at the engine global level, it sounds reasonable that #11019 also follows the same approach given that the change is minor.

    Yeah as a stopgap it makes sense. I also want to use it as forcing function to clarify the design we want to converge towards.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions