Skip to content

NFS mounts #9326

Closed
Closed

Description

@shykes

Problem

Dagger doesn't support mounting NFS directories directly into containers. Instead, the user must mount them into the client machine, and copy them from there into the engine, like any other host directory. This works reliably, but is less efficient than a direct bind-mount.

Solution

At this time there is no design for bypassing the copy into the engine. Nikola Jokic has proposed implementing support for direct bind mounts, which would indirectly solve the problem for NFS. However this opens a can of worms: the host running the dagger engine container ("engine host") may not be the same host running the dagger CLI ("CLI host"), and so far we have been careful to only expose the CLI host. Allowing direct bind mounts would break this abstraction, thus forcing us to clarify the distinction between "cli host" and "engine host" and make a series of important design and architecture decisions.

So, the first step to implementing support for NFS mounts is to resolve the underlying design questions:

  • Do we want to distinguish "engine host" and "cli host"?
  • If so, how do we expose each in the API? How do we explain the difference?
  • How do we avoid weakening and fragmenting the platform? See for example Docker, where the engine alone is blind to the client system - it requires an external wrapper (desktop app) to bridge "client host" and "engine host".
  • If we want to continue distinguishing "cli" and "engine", what do we want the protocol between them to be? Today there is an experimental and undocumented "runner host" protocol. This can't go on forever.
  • Do we even want the engine and cli to be two distinct entities forever? In the past we talked about "one big binary"; and we talked about clarifying that Dagger is a container engine. To decide on the above, we probably need to decide on this too.

So as you can see 👆 the road to NFS support goes through a pretty intense set of design decisions. But these decisions have been postponed for too long, so maybe this feature request is the push we needed to get it done :)

Calling for comments! @sipsma @cwlbraa @jedevc @vito @marcosnils @gerhard

Activity

  1. jedevc commented on Jan 7, 2025

    @jedevc
    Contributor

    I'm kind of interested into diving into what the NFS mounts are going to be used for 👀

    • is it for avoiding the expensive context transfer of files?
    • is it to enable a faster speed between an engine-fileserver while the cli is remote and slow?
    • is it to allow a writeback to the NFS server?

    The use case determines what we'd want to build here I think - whether it can be entirely transparent, or whether there's a dag.NFS equivalent like we have dag.Git, etc.


    I've also really wanted to use direct bind mounts as a way to avoid the incredibly expensive file network transfer - we could just replace it with a copy (note: keeping a copy of some sort is still somewhat required to get good consistency and caching behavior). I think it's pretty doable, since the dagger container runs as privileged.

    But, the way I've previously thought about this is as just an optimization - you still wouldn't be able to write directly back to the bind mount. If the cli/engine are running on different hosts, you'd just fallback to the file network transfer we use today. This use case feels a bit different, but thought I'd raise it here anyways.


    Do we want to distinguish "engine host" and "cli host"?

    Not really sure on any of the other points you've mentioned, but I'd like to avoid the concept of a distinct configurable "engine host" at all. Aside from configuring some engine settings (which enable features like GPUs, or configure garbage-collection, etc), I think we should avoid having special "pet" engines (as opposed to generic "cattle" engines).

    Running dagger -m my-module should work on any engine. A potentially long-running engine shouldn't need to be setup to handle special NFS mounts, it should be able to be configured on-the-fly from the caller (whether that's one binary, or still the same cli-engine split, or whether a new engine is transparently created, or an old one reused).

  2. sipsma commented on Jan 7, 2025

    @sipsma
    Contributor

    I'm curious to know the specifics of the use case here, especially around how the data in the NFS mount would be used. The two categories of data we support currently are "immutable recipe-defined layers" and "mutable cache mounts". I'm guessing the use case here probably follows the "mutable cache mounts" pattern, but want to confirm. I think this actually impacts the design pretty significantly.

    I can't tell yet how much this relates back to the engine/cli split. Theoretically you could just give the engine the NFS config and have it create its own mount for it (at which point it's just a certain named cache mount). But I don't mind a forcing function around that whole design either since I agree it's been in limbo for too long.

    EDIT: after posting my comment the page reloaded and revealed Justin's comment, sorry if I'm duping anything 🙂

  3. IljaKroonen commented on Jan 8, 2025

    @IljaKroonen

    We run Dagger on hosts with mounted fileshares used for file uploads/downloads. Programs may read configuration files from these shares, upload files for external API processing, or download files generated by APIs.

    Currently, this workflow isn't supported in Dagger, restricting its use to a subset of CI workflows.

    is it for avoiding the expensive context transfer of files?
    is it to allow a writeback to the NFS server?

    Yes to both. These fileshares are too large to copy, and we need read/write capabilities for specific use cases.
    Regarding the "one binary approach," I don’t foresee use cases requiring the engine to run separately from the client for our scenarios.

  4. shykes commented on Jan 8, 2025

    @shykes
    ContributorAuthor

    @IljaKroonen have you tried copying the files into dagger from the host, with pre-call filtering to only copy what you need? I understand that the entire NFS mounts are surely too large to copy, but how much data do you actually need to copy into dagger? Depending on the answer you may not need a new feature at all, and may be able to get a solid implementation with pre-call filtering.

  5. IljaKroonen commented on Jan 9, 2025

    @IljaKroonen

    We can use dagger to read and write files to and from the shares (using pre-call filtering for example, and file exports) but this means that we need to exactly know ahead of time what files we will need; and it means we need to use dagger DSLs / calls every time we need to interact with the actual share.

    A typical suite of integration tests would read / write a variety of files (similar to how some other software would use S3 storage service) and we want to be able to tell dagger "run these integration tests" (which we can do today outside of dagger, for example running in an IDE and running in Jenkins directly), rather than re-implementing the test suite with a complicated sequence of dagger function calls.

  6. shykes commented on Feb 4, 2025

    @shykes
    ContributorAuthor

    After live discussion with @sipsma, @jpadams , @IljaKroonen and team:

    • NFS in @IljaKroonen 's case is an application dependency (similar to how an app might require an S3 bucket). The files on those shares are live application data and not build artifacts. Therefore relying on local directories and pre-call filtering is not an appropriate in this case
    • Open-ended support for arbitrary bind-mounts into the engine container are not an attractive option, because it would cause mixing of infrastructure and application concerns, which goes counter to Dagger's design. eg. "please infra team could you configure these 3 new NFS mounts in the production dagger cluster, so that I can mount them in my application build?"
    • It appears that supporting NFS volumes natively is indeed the best approach. Besides some superficial API bikeshedding, we ancitipate that the main bottleneck will be engineering bandwidth to contribute the feature
    • @IljaKroonen and his colleagues are volunteering to make the contribution, thank you! 🙏
    • Lastly, once we do NFS, it seems reasonable to also support SMB, expanding the same design.
  7. IljaKroonen commented on Feb 24, 2025

    @IljaKroonen

    After investigating this a bit more:

    • having the ability to mount NFS shares in dagger would solve our problem but I don't think this is practical to implement. The environment in which we run won't allow us to mount directly using the Linux NFS driver and while a fuse implementation exists, I am not sure how reliable it is
    • same issue for SMB - I did try the fuse implementation and it seems to have issues / functionalities that are not fully implemented
    • I tried the SSH fuse mount and that worked well - it requires --device /dev/fuse --cap-add SYS_ADMIN and works in our environment.

    We would run a component that exposes the shares via SSH alongside the dagger engine - and the dagger engine would mount the shares from it. In terms of dependency, the dagger workflow itself would depend only on the network access needed to connect to the share.

    What are your thoughts? I think we can come up with a design that makes it fairly easy to add more fileshare protocols, as mounting shares is done by invoking a command. Using a hypothetical DSL to mount a share inside a container inside dagger would probably do something along the lines of:

    • invoke a protocol-specific command in the engine container to mount the share
    • invoke the container command with that directory bind mounted
    • invoke a protocol-specific command in the engine to unmount the share when done
  8. IljaKroonen commented on Feb 28, 2025

    @IljaKroonen

    Thinking ahead - what would this DSL look like?

    If we take the sshfs example we would roughly have these inputs:

            dag.container()
                .with_mounted_sshfs("/mnt/myshare", remote="ssh-fs-server.some.zone:/mnt/", user = "example-user", private_key = private_key_secret, host_public_key = host_public_key)
    

    This does not generalize very well - if would require an additional DSL for each share type. We can have a driver = "sshfs" (and later NFS, SMB...) but the shape of the argument might be different due to the various kinds of inputs required (especially given there are different methods of authentication).

  9. sipsma commented on Mar 13, 2025

    @sipsma
    Contributor

    having the ability to mount FFS shares in dagger would solve our problem but I don't think this is practical to implement. The environment in which we run won't allow us to mount directly using the Linux NFS driver and while a fuse implementation exists, I am not sure how reliable it is

    Ah okay, good to know. I'm guessing it gets into something deeply specific to your setup, but if you are able to share why it doesn't work I'd be curious to know. I did a quick hacky test with my own NFS server and hardcoding the engine to create NFS mounts from it and it worked, so just wondering where the delta is coming from.

    I tried the SSH fuse mount and that worked well - it requires --device /dev/fuse --cap-add SYS_ADMIN and works in our environment.

    Yeah that sounds like a reasonable fallback option. It would be very nice to have NFS/SMB directly but SSHFS is generally useful enough too that we could start there if it's what unblock you sooner. In the end support for all these different mount types can coexist harmoniously I think.

    IIUC this will require that the userspace driver for SSHFS exists in the engine container. Those don't look to be very large dependencies at all (e.g. in alpine), so I'd be totally fine with updating the dagger engine base image with those.

    @IljaKroonen one question though, how does SSHFS handle multiple clients mounting the same remote filesystem in parallel? E.g. if two containers had an SSHFS mountpoint pointing to the same remote would they be able to execute in parallel? If not, there's multiple ways of dealing with this in the engine, just want to check if any extra work would be involved there.


    This does not generalize very well - if would require an additional DSL for each share type. We can have a driver = "sshfs" (and later NFS, SMB...) but the shape of the argument might be different due to the various kinds of inputs required (especially given there are different methods of authentication).

    There's another general concern too around leaking "operator concerns" into "developer code". We've generally tried to avoid creating APIs that enable dagger code which can only possibly work on a single machine (or set of machines), for a few reasons:

    1. It makes it easy to just hardcode values inline into APIs like with_mounted_sshfs that then need to be updated whenever infra is modified and thus churn between infra operators and developers. Users can set up a bunch of plumbing to make it all dynamically configured, but that's extra work for them.
    2. It opens more doors to footguns like re-usable modules being published that have API calls that only work in some engines.

    That isn't a super-hard blocker for me necessarily, but I do think it's worth considering an alternative that might avoid them.

    Summarizing two options below:

    Option 1 - with_mounted_sshfs

    This is what @IljaKroonen proposed with:

            dag.container()
                .with_mounted_sshfs("/mnt/myshare", remote="ssh-fs-server.some.zone:/mnt/", user = "example-user", private_key = private_key_secret, host_public_key = host_public_key)
    

    In this approach, I'd personally prefer having a different API for each mount type vs. one API field that takes a million different config options. That takes advantage of dagger's type system more to ensure you can only provide the right config args to the right APIs. API bloat is a legit concern, but in the other approach we'd just be bloating the API in terms of random config options on a single field.

    Given that, I think the example API you posted makes sense if we go this route. We'd want to make sure the private_key arg is of type Secret so it doesn't end up persistently cached on disk. Otherwise they all look like strings.

    In terms of caching semantics, these types of mounts would be treated essentially the same as CacheVolumes, i.e. treated as an opaque blob (not content hashed or layered, etc.). We'd probably just use the remote as the cache key (which impacts when dagger re-runs containers that have the mount included).

    Pros:

    • nicely typed API usable from any SDK

    Cons:

    • aforementioned downside of mixing operator+developer concerns together

    Option 2 - engine config mounts

    In this approach we'd try to avoid an API that hardcodes infra-specifics as arguments in developer code.

    Instead, we'd update /etc/dagger/engine.json to handle a new config option for CacheVolumes. Sketched out:

    "cacheVolumes": {
       "my-sshfs-mount": {
         "type": "sshfs",
         "remote": "ssh-fs-server.some.zone:/mnt/",
         "user": "example-user",
         "private_key": {
           "file": "/path/to/private/key/in/engine/container.pem"
       }
    }

    Then, we'd update Container.withMountedCache such that if you run an engine with the above config and made a call like

    dag.container().
      with_mounted_cache("/mnt/myshare", dag.cache_volume("my-sshfs-mount"))
    

    The cache volume would be sourced from the special sshfs mount configured in engine.json rather than its usual source. The connection between the two is the name "my-sshfs-mount".

    • in time we'd obviously be able to add more types than just "sshfs"
    • also, since the private_key is a secret, it probably makes sense to support reading it from a file, from an env, etc. That's why I wrapped it in {"file": "..."}

    I think this works reasonably well because the semantics of these types of special "external mounts" pretty closely matches the semantics of cache volumes anyways.

    It also avoids mixing operator/developer concerns too deeply because if someone ran that code and "my-sshfs-mount" didn't correspond to a special configured cache volume, then it would still work and just fallback to the default cache volume behavior.

    Then, whenever any configuration around infra needs to change, the infra operator just needs to update the engine container's config file and all other dagger code maintained by devs can continue working the same.

    The only gotcha I can think of is if this configuration needs to update a lot and/or be dynamic somehow. But there's likely ways of dealing with it if so.

    Pros:

    • Avoids operator/developer entanglement

    Cons:

    • Gets more complicated if frequent and/or fully dynamic config is required (TBD if that's a real world issue yet or just hypothetical)

    Overall I'm currently leaning towards Option 2 as my favorite, but let me know what you think and what I missed @IljaKroonen

    cc @shykes @jedevc

  10. IljaKroonen commented on Mar 14, 2025

    @IljaKroonen

    Ah okay, good to know. I'm guessing it gets into something deeply specific to your setup, but if you are able to share why it doesn't work I'd be curious to know. I did a quick hacky test with my own NFS server and hardcoding the engine to create NFS mounts from it and it worked, so just wondering where the delta is coming from.

    The environment where we run dagger (CLI and engine) does not have full capabilities - we are using the Linux user namespaces and identity mapping. We can use fuse, however.

    how does SSHFS handle multiple clients mounting the same remote filesystem in parallel?

    I've tested this just now and it works fine - I can mount the same folders from the same source several times in different locations and these all work at the same time

    Both approaches you propose will solve for our use case, and I'm happy with either.

    There's another general concern too around leaking "operator concerns" into "developer code". We've generally tried to avoid creating APIs that enable dagger code which can only possibly work on a single machine

    In the particular case of SSHFS, we are using network access to mount the share - what case are you thinking of where this would be specific to a single machine / setup? The main prerequisite here would be for the SSH server to be accessible from the engine which feels similar to using an HTTP api from dagger (analogous to using S3).

    Gets more complicated if frequent and/or fully dynamic config is required

    FWIW in our case this would pretty much never change

  11. sipsma commented on Mar 20, 2025

    @sipsma
    Contributor

    In the particular case of SSHFS, we are using network access to mount the share - what case are you thinking of where this would be specific to a single machine / setup? The main prerequisite here would be for the SSH server to be accessible from the engine which feels similar to using an HTTP api from dagger (analogous to using S3).
    ...
    FWIW in our case this would pretty much never change

    Yeah when considering just purely your use case, putting operator specific details in code is less of an issue. I'm just thinking through what we'd be enabling in general since other users would obviously come up for this.

    You're 100% right that our current API does enable hard-coding highly host/network specific details that aren't guaranteed to work on any machine (http, container images, a withExec that hits network endpoints, etc.). This isn't something we've been "pure" about in the past and have tried to find practical compromises (or just didn't really consider this whole issue at the time).

    However, when adding new APIs I think it's still worth seeing if we can avoid deepening these sort of problems. I think the fact that Option 2 enables operators to seamlessly update the infra-specific configuration w/out any code change to developers dagger code is a clear enough benefit to justify going with this sort of approach.


    Current Status

    • Sounds like @IljaKroonen is good with either option, so no blockers there
    • Need feedback from others on Dagger team to finalize decision on the approach we go with here
  12. shykes commented on Mar 21, 2025

    @shykes
    ContributorAuthor

    @sipsma I see the appeal of option 2: move infrastructure-specific concerns below the application/infra separation line. I'm asking myself 2 questions:

    1. Are these particular infrastructure-specific concerns worth moving below the line, or are they more like the other "purity tradeoffs" you mentioned, like hostnames that may or may not resolve everywhere, etc.

    2. Assuming they do belong below the line: should we follow the template of secret providers, our most recent implementation of moving infrastructure-specific concerns below the line? In practice that would mean: make your function take a cache volume as argument; then add support in the API for instantiating cache volumes from different providers. This removes one aspect of option 2 which is relying on volume name as a loose "contract" between infra and app layers. Smells of "shadow API" if you know what I mean?

  13. sipsma commented on Mar 24, 2025

    @sipsma
    Contributor

    Are these particular infrastructure-specific concerns worth moving below the line, or are they more like the other "purity tradeoffs" you mentioned, like hostnames that may or may not resolve everywhere, etc.

    This feels different to me, primarily because almost every setting of SSHFS/NFS/etc. endpoints is going to be infra-specific (there's not many or really any public endpoints for these protocols). Contrast that with hitting some arbitrary HTTP endpoint where the vast majority of usage is not infra-specific and thus makes the appeal of purity far lower.

    Additionally, I think the benefit of this approach is pretty clear cut in the example where users can write dagger code w/ no infra-specific config and infra operators can modify it by just updating the engine config file. That saves users from the choice of:

    1. hardcode values in their own code, require infra operators update that code whenever a change is needed
    2. set-up a ton of their own plumbing to make these updates seamless

    That entire problem is just entirely eliminated in this approach.

    Assuming they do belong below the line: should we follow the template of secret providers, our most recent implementation of moving infrastructure-specific concerns below the line? In practice that would mean: make your function take a cache volume as argument; then add support in the API for instantiating cache volumes from different providers. This removes one aspect of option 2 which is relying on volume name as a loose "contract" between infra and app layers. Smells of "shadow API" if you know what I mean?

    Yeah I like that idea. I think with the right approach we can also retain the niceties mentioned above but in a way that's easier to implement iteratively.

    Fleshing out with some more details:

    Do go with the approach of different APIs for each type of mounted filesystem, e.g.

    • sshfsVolume(endpoint: String!, user: String!, privateKey: Secret!, publicKey: String!): CacheVolume!

    Do not allow function implementations to call sshfsVolume; they must be provided as a CacheVolume argument if used.

    The above should be enough to satisfy the most basic use cases.

    To get more polish we can iteratively add support for reading the volume configuration from the engine-wide config and/or user-config, somewhat conceptually similar to .env support for secrets.

    @shykes is that aligned with what you were thinking?

  14. shykes commented on Mar 24, 2025

    @shykes
    ContributorAuthor

    Do go with the approach of different APIs for each type of mounted filesystem, e.g.

    • sshfsVolume(endpoint: String!, user: String!, privateKey: Secret!, publicKey: String!): CacheVolume!

    Do not allow function implementations to call sshfsVolume; they must be provided as a CacheVolume argument if used.

    The above should be enough to satisfy the most basic use cases.

    To get more polish we can iteratively add support for reading the volume configuration from the engine-wide config and/or user-config, somewhat conceptually similar to .env support for secrets.

    Follow-up questions:

    1. Is the idea that sshfsVolume() would only be available to external clients, kind of like host()? And similar to my proposal for secret providers, which we punted on for now?
    2. How would these new functions be called? From the Dagger CLI? And if so, how would the end-user specify it? Simplified URI like secret providers (but maybe over-simplified?); or call from the shell (but lose support for dagger call)?
    3. This feels like a Volume more than a CacheVolume. Perhaps we could define a new Volume type, and make it an interface so that CacheVolume can retroactively implement it?
  15. sipsma commented on Mar 26, 2025

    @sipsma
    Contributor

    Is the idea that sshfsVolume() would only be available to external clients, kind of like host()?

    Yes

    How would these new functions be called? From the Dagger CLI? And if so, how would the end-user specify it? Simplified URI like secret providers (but maybe over-simplified?); or call from the shell (but lose support for dagger call)?

    Use from an SDK executing directly on the host is a viable option too. But in terms of the CLI, yeah for a first iteration I'd be totally fine w/ just needing to use shell.

    What I mentioned "to get more polish we can iteratively add support for reading the volume configuration from the engine-wide config and/or user-config" would be an improvement and make it easily configured in a file and then referred to by name/identifier in any CLI command. But that doesn't have to be part of a first iteration necessarily.

  16. IljaKroonen commented on Mar 28, 2025

    @IljaKroonen

    just needing to use shell.

    What does "needing to use shell" entail? In the model we currently use, Jenkins invokes a single dagger function (using dagger call) and passes in the git repository and auth. What would this look like if we also wanted to make a directory available under your proposal?

  17. sipsma commented on Mar 28, 2025

    @sipsma
    Contributor

    What does "needing to use shell" entail? In the model we currently use, Jenkins invokes a single dagger function (using dagger call) and passes in the git repository and auth. What would this look like if we also wanted to make a directory available under your proposal?

    It would be something as simple as e.g.

    dagger shell -c 'some-function --mount $(sshfsMount "endpoint" --private-key=file://some/key.pem)'
    

    dagger call just has the limitation that it's hard to provide complex objects created by other API calls as args, whereas dagger shell has the syntax support that makes it easy.

    Generally speaking, any dagger call can very easily be translated to an equivalent dagger shell -c command, so this shouldn't require any big changes.

  18. shykes commented on Mar 28, 2025

    @shykes
    ContributorAuthor

    just needing to use shell.

    What does "needing to use shell" entail? In the model we currently use, Jenkins invokes a single dagger function (using dagger call) and passes in the git repository and auth. What would this look like if we also wanted to make a directory available under your proposal?

    Basically, the dagger shell supports explicitly passing the output of one function as argument to another, using the familiar subcommand syntax of the bash syntax. For example:

    dagger -c 'container | from alpine | with-directory /src $(git https://github.com/dagger/dagger | head | tree)'
    

    This also works for host access, which is part of the Dagger API like everything else:

    dagger -c 'container | from alpine | with-directory /home/dev $(host | directory .) | with-unix-socket /var/run/docker.sock $(host | socket /var/run/docker.sock)'
    

    But, dagger call on the other hand does not support this kind of composition. So as a convenience, it will decode command-line arguments in a type-aware way: depending on the type of each argument, the corresponding CLI arg will be parsed differently:

    • For args of type Directory, the CLI will allow git URIs like https://github.com/dagger/dagger#main:/docs which it will resolve by calling git() etc. Or of you provide a local path, it will resolve it by calling host().directory().
    • For args of type Secret, the CLI supports URI schemes like env://, op://, vault://, etc.

    What we were discussing here was: should we implement a similar convenience for arguments of type CacheVolume, where URIs like sshfs:// are supported, and if so, what should the URI format, can it fit all the allowed parameters without becoming too complex etc.

    OR do we skip implementing the CLI convenience, only implement the underlying API call - but without that convenience dagger call will not have the ability to create those volumes.

    • dagger call my-function --my-volume=sshfs://foo:bar#baz?a=b&x=y
    • dagger -c 'my-function --my-volume=$(sshfs-volume foo:bar --name=baz --a=b)

    I hope this helps!

  19. sipsma commented on Mar 28, 2025

    @sipsma
    Contributor

    What we were discussing here was: should we implement a similar convenience for arguments of type CacheVolume, where URIs like sshfs:// are supported, and if so, what should the URI format, can it fit all the allowed parameters without becoming too complex etc.

    Given any convenience like that can be layered on later backwards-compatibly, I will leave it up to whoever implements this to decide if they want to pursue that. I'm fine w/ skipping it to start though.

    Excluding the above, are there any blockers left on the design for you @shykes? If not, I can do a final summary of all the above and it'll be ready to be implemented

  20. shykes commented on Mar 28, 2025

    @shykes
    ContributorAuthor

    Excluding the above, are there any blockers left on the design for you @shykes? If not, I can do a final summary of all the above and it'll be ready to be implemented

    Yeah no blockers from me, it boils down to:

    1. Bikeshedding the API design for new volume constructors (I think we should implement it regardless, unlike secret providers where we'll have to retrofit - do you agree?)
    2. Deciding on adding a convenience URI format now vs. later
    3. Possible introduction of a Volume type, since these new backends have very different persistence properties (not best effort in the same way) so now might be a good time to shed the baggage of the word "cache".

    Other than that, I agree with the direction.

  21. sipsma commented on Apr 10, 2025

    @sipsma
    Contributor

    Bikeshedding the API design for new volume constructors (I think we should implement it regardless, unlike secret providers where we'll have to retrofit - do you agree?)

    Yeah I want there to be APIs for each volume type, if that's what you're getting at (sshfsVolume, nfsVolume, etc.)

    Deciding on adding a convenience URI format now vs. later

    Really no strong opinion on this. I feel like it can be safely saved until it's desired by anyone. In the meantime invoking from shell or an SDK on the host suffices.

    Possible introduction of a Volume type, since these new backends have very different persistence properties (not best effort in the same way) so now might be a good time to shed the baggage of the word "cache".

    Sure, yeah that makes sense to me. Probably what it should have been named in the first place, hindsight being 20/20 and all that.


    So to summarize:

    API would look like:

    type Query {
       sshfsVolume(endpoint: String!, privateKey: Secret!, publicKey: String!): Volume!
    }
    
    type Volume {
       // not sure we need anything here yet besides just the autogenerated id field
    }
    
    type Container {
       withMountedVolume(path: String!, volume: Volume!): Container!
    }
    

    We'd block sshVolume from being called in modules; only callable by the main client on the host.

    To start, would be invoke-able either from an SDK running on the host or, if using the CLI, like

    dagger -c 'my-function --my-volume=$(sshfs-volume foo:bar --private-key=$(secret("<secret uri>")) --public-key=foobar)'
    

    cc @IljaKroonen

  22. sipsma commented on May 8, 2025

    @sipsma
    Contributor

    Local dev docs can be found here, but will outline some more pointers specific to this effort.

    cc @IljaKroonen and team

    Implementation

    Will give a high-level outline here, obviously happy to fill in details as needed.

    API schema

    We'll want a new Volume type and associated Query.sshfsVolume API for creating one.

    You'll also want to add Container.withMountedVolume

    After setting up the above and any subsequent API changes you can regenerate SDKs to make the new APIs available to clients.

    • Just regenerate the Go SDK (important for the integ tests)
      • dagger call sdk go generate export --path . (run from the root of the dagger repo)
    • Regenerate all SDKs (slower, but needed before final merge)
      • dagger call sdk all generate export --path .

    Plumbing + Mount Setup

    Testing

    Can add a new integ test anywhere in ./core/integration.

    If you for example add func (EngineSuite) TestSSHFSVolume to engine_test.go then you can run just that test with

    dagger call test specific --pkg ./core/integration --run='TestEngine/TestSSHFSVolume
    

    That will build the engine from your local changes, run it as an ephemeral dagger service and execute that test against it, all in one command.

    An alternative I often follow is to build a dev engine and run it in docker standalone and then execute tests against it. This has the advantage of being easier to debug since the engine is long-running rather than an ephemeral service. To do this:

    • ./hack/dev rebuilds the engine from your local changes and deploys it into docker (named dagger-engine.dev)
    • To run tests against that engine ./hack/with-dev go test -v -run TestEngine/TestSSHFSVolume ./core/integration. Can re-run tests as needed w/out rebuilding the engine necessarily
    • You can then see engine logs with docker logs dagger-engine.dev, exec into the engine with docker exec dagger-engine.dev sh, etc.
    • If you want to test the CLI against this dev engine, you can just use ./bin/dagger (from the root of the repo); it will be rebuilt by ./hack/dev alongside the engine and connect to the dagger-engine.dev container automatically

    Setting up the test will be a bit intricate since it'll require running an sshfs server that's available to the engine.

    If you just want to get going quickly you could just setup your own sshfs server on the side and run tests locally against that for now.

    But for the final merged PR we'll want the tests to work standalone. Can figure out details later but a basic outline would be:

    • use devEngineContainer util to get a dev engine as a dagger container
    • attach a service dependency on a SSHFS server (encapsulated in a dagger container)
    • run tests against that engine container (see this example for opening a client against one of these engines)
  23. nikola-jokic commented on Sep 23, 2025

    @nikola-jokic
    Contributor

    Hey @sipsma, @shykes,

    I managed to make the volume mount shared from the host, but I have a few issues I'd love to discuss about the design.

    1. The sshfs ideally shouldn't be container-based API. The reason is that pulling a large filesystem and unmounting before running the next container can be expensive compared to mounting the filesystem once, sharing that directory between containers, and unmounting. However, it does go against the proposed design.
    2. Mounting sshfs inside the engine container would require the engine to be started with the driver that can mount the sshfs. This can conflict with your original design, which separates the platform from the workflow. Unless the engine container is configured to be able to mount the sshfs, the sshfs volume mount would fail. Please correct me on this point if I'm wrong, but everything is pointing in that direction.

    Depending on the answers, I can continue implementing this feature. So far, I've used the host mount inside the engine. That is assuming that the directory is already present. Now, I need to build on top of it, which leads to these concerns.

    CC @IljaKroonen if you have anything to add, please do ☺️

  24. sipsma commented on Sep 29, 2025

    @sipsma
    Contributor
    1. The sshfs ideally shouldn't be container-based API. The reason is that pulling a large filesystem and unmounting before running the next container can be expensive compared to mounting the filesystem once, sharing that directory between containers, and unmounting. However, it does go against the proposed design.

    I don't follow. It would be perfectly fine for the engine to mount the sshfs once and then share that mount by just bind mounting it into each container that needs it. Where would that not work with the container API?

    1. Mounting sshfs inside the engine container would require the engine to be started with the driver that can mount the sshfs. This can conflict with your original design, which separates the platform from the workflow. Unless the engine container is configured to be able to mount the sshfs, the sshfs volume mount would fail. Please correct me on this point if I'm wrong, but everything is pointing in that direction.

    It's totally fine for the engine to have a dependency on sshfs/fuse/etc. You can update the engine container to install any deps (./cmd/engine/.dagger/builder.go)

  25. IljaKroonen commented on Sep 29, 2025

    @IljaKroonen
    1. The sshfs ideally shouldn't be container-based API. The reason is that pulling a large filesystem and unmounting before running the next container can be expensive compared to mounting the filesystem once, sharing that directory between containers, and unmounting. However, it does go against the proposed design.

    I don't follow. It would be perfectly fine for the engine to mount the sshfs once and then share that mount by just bind mounting it into each container that needs it. Where would that not work with the container API?

    1. Mounting sshfs inside the engine container would require the engine to be started with the driver that can mount the sshfs. This can conflict with your original design, which separates the platform from the workflow. Unless the engine container is configured to be able to mount the sshfs, the sshfs volume mount would fail. Please correct me on this point if I'm wrong, but everything is pointing in that direction.

    It's totally fine for the engine to have a dependency on sshfs/fuse/etc. You can update the engine container to install any deps (./cmd/engine/.dagger/builder.go)

    I think I might have misunderstood what the DSL does in the design above.

    For example if I call

    sshfsVolume(endpoint: String!, privateKey: Secret!, publicKey: String!): Volume!
    

    My interpretation would be that this does not do anything besides storing the values passed, such that the mount actually happens when mounting inside a container process executing a command.

    But I think you are saying it would actually run the mounting upon being called?

    This creates some further questions - what if I call it twice? Does it reuse based on the arguments being the same? What about unmounting?

  26. IljaKroonen commented on Jan 30, 2026

    @IljaKroonen

    I can confirm that Nikola's patch is working for our use case.

    You can see it here: https://github.com/G-Research/dagger/tree/nikola-jokic/sshfs-volume

    Both these methods in there are suitable for us:

    • dag.SshfsVolume successfully connects to our host and allows accessing the files from WithExec
    • the WithMountedHostDirectory also achieves what we want pretty much directly but my understand from the above that we would like to avoid exposing this kind of primitive (I think the name could be more explicit too, maybe it should be named WithMountedEngineHostDirectory or something like that)

    (The reason we are fine with WithMountedHostDirectory is because the directory we mount is always the same - but that might not apply to other users so I can see how SshfsVolume makes more sense for the dagger project and its design)

    We're looking for feedback on getting the capability merged in. What next steps do you suggest? Is there anything we should make sure of before contributing back SshfsVolume (or WithMountedEngineHostDirectory) ?

  27. locked and limited conversation to collaborators on Mar 25, 2026
  28. converted this issue into a discussion #12541 on Mar 25, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions