diff --git a/website/content/docs/job-specification/hcl2/functions/file/file.mdx b/website/content/docs/job-specification/hcl2/functions/file/file.mdx index 894ccd891..6d1c07d36 100644 --- a/website/content/docs/job-specification/hcl2/functions/file/file.mdx +++ b/website/content/docs/job-specification/hcl2/functions/file/file.mdx @@ -9,7 +9,7 @@ description: |- # `file` Function `file` reads the contents of a file at the given path and returns them as -a string. +a string. Relative paths will be resolved based on the CLI’s current working directory. ```hcl file(path) @@ -30,6 +30,31 @@ so this function can only be used with files that are already present on disk on Hello World ``` +Or in an example job specification: + +```hcl +# /path/to/example/jobspec.nomad +job "test" { + group "test" { + task "test" { + driver = "docker" + config { + image = "test/image:latest" + + volumes = [ + "local/file.txt:/path/to/file/on/container/file.txt" + ] + } + + template { + data = file("/path/to/example/file.txt") + destination = "local/file.txt" + } + } + } +} +``` + ## Related Functions - [`fileexists`](/nomad/docs/job-specification/hcl2/functions/file/fileexists) determines whether a file exists