#Bind mount

1 messages · Page 1 of 1 (latest)

buoyant warren
#

The mounts in dagger aren't like bind mounts in docker, which are bidirectional. These are more like snapshots. What you need in this case is a cache volume which you can use in with_mounted_cache.

honest mango
#

@buoyant warren oh that's a surprise as a user. Is there an easy way to get data out of the cache volume?

buoyant warren
#

The example you provided in #general message isn't clarifying to me what your use case is though. In that simple example there's no need for the mount. Do you expect to mount it again in another place in an implicit way to get those files?

#

\cc @strong void

buoyant warren
#

Oh, from re-reading your list above you want to get data out of what a service adds to a directory. You can later add the cache mount to another container to with_exec something on those files, or cp them to another location if you need to export it. Depends on what you need to do with that data.

honest mango
#

I think I was able to achieve that through a cache mount. Accessing the cache data directly was a challenge so I had to mount it into a dummy container that dumped out.

strong void
#

If you're using dagger 0.9.3 it's easier to achieve this by using the new service lifecycle APIs. You can just stop the service after your pipeline is finished and then use the Export method directly from the service container

honest mango
#

@strong void how do I get the container from the service?

strong void
# honest mango <@336241811179962368> how do I get the container from the service?

a Container can be changed to a Service with the AsService method.

So if you have something like this:

    // create HTTP service container with exposed port 8080
    httpCtr := client.Container().
        From("python").
        WithDirectory("/srv", client.Directory().WithNewFile("index.html", "Hello, world!")).
        WithWorkdir("/srv").
        WithExec([]string{"python", "-m", "http.server", "8080"}).
        WithExposedPort(8080)

    httpSrv := httpCtr.AsService()

^ there you have the httpCtr and httpSrv variables

#

you just need to remember to call Stop on the service variable before exporting any files