#Can i write to local fs using a Directory as a function input
1 messages Β· Page 1 of 1 (latest)
In the Run function i call a container with
WithMountedDirectory(outputDirMountPath, outputDir)
I verified using terminal that the files exists in the container mounted directory. However in the local FS they were not created.
Maybe do i need to return the Directory instead of the Container π€ but i still need to write to that folder the outputs
exporting the directory works
*Mounted files and Directories are not persisted in the final container if you export or publish it
just tried it out but does not seem to work
example:
func (m *Lala) Lala() *Container {
testFile := dag.Directory().WithNewFile("/test", "foo").File("/test")
return dag.Container().From("alpine:latest").
WithMountedFile("/test", testFile)
}
you can then:
dagger call lala file --path /test export --path ./test.txt
the SDK one should also work
hmm
oh sorry
you shouldn't call export in the SDK
you can return the *Directory or *File type
that's what I meant
and use export in the CLI
exporting in the SDK doesn't really export to the host machine, but to the runtime container
oh gotcha
to the sandbox container
lets say
gonna try the one from the cli instead then
yes, exactly
π
is not exporting the directory still π€ do you see where am i messing it up?
dagger call run ... directory --path /output export --path ~/tmp/out/
being /output the directory in the container with the results and ~/tmp/out/ where i want to export them to
nvm it works
I was just typing that it worked to me π
so that works just fine then nice
remember you can use the terminal command to check what's in the underlying container

I might have a similar use case to this. Can you somehow persist what is mounted in a cache? In my case, it is migrations applied to a database.
the contents of a cache volume you mean Deniz?
in that case you can run a WithExec cp command after the volume is populated and copy whatever files you need into the resuling Container to be published / exported
I guess you're referring to https://discord.com/channels/707636530424053791/1260558982246825994 correct? let me reply there