Skip to main content

Host Filesystem Access

Dagger Functions do not have access to the filesystem of the host you invoke the Dagger Function from (i.e. the host you execute a CLI command like dagger call from). Instead, host files and directories need to be explicitly passed when executing dagger call.

To pass host files and directories as arguments when invoking a Dagger Function, specify their path as the value of the argument when using dagger call.

Here is an example of passing a host directory as argument to a Go builder Dagger Function:

git clone https://github.com/golang/example
dagger -m github.com/kpenfound/dagger-modules/golang@v0.1.8 call build --source=./example/hello --args=. directory --path=. entries

Here is an example of passing a host file to a container builder Dagger Function using the WithFile() function:

dagger -m github.com/shykes/daggerverse/wolfi@v0.1.2 call container with-file --path=/README.md --source=./README.md with-exec --args="cat","/README.md" stdout

Here is another example of passing a host file as argument to a checksum Dagger Function:

dagger -m github.com/jumppad-labs/daggerverse/checksum@49dff54b421df9844fec87766e3710138bc98914 call calculate-from-file --file=~/.profile

To pass a secret stored in a host file as argument when invoking a Dagger Function, add the file: prefix to the file path value.

Here is an example of passing a host file containing an access token to a Dagger Function as a secret:

dagger -m github.com/aweris/daggerverse/gh@99a1336f8091ff43bf833778a324de1cadcf25ac call run --token=file:/home/admin/github-token.txt --cmd="issue list --repo=dagger/dagger"