Skip to content

Commit 96c467e

Browse files
authored
docs: add copy command examples and description (flyteorg#5782)
Signed-off-by: mao3267 <[email protected]>
1 parent d8afbcc commit 96c467e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/user_guide/customizing_dependencies/imagespec.md

+20
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ image_spec = ImageSpec(
175175
)
176176
```
177177

178+
## Copy additional files or directories
179+
You can specify files or directories to be copied into the container `/root`, allowing users to access the required files. The directory structure will match the relative path. Since Docker only supports relative paths, absolute paths and paths outside the current working directory (e.g., paths with "../") are not allowed.
180+
181+
```py
182+
from flytekit.image_spec import ImageSpec
183+
from flytekit import task, workflow
184+
185+
image_spec = ImageSpec(
186+
name="image_with_copy",
187+
registry="localhost:30000",
188+
builder="default",
189+
copy=["files/input.txt"],
190+
)
191+
192+
@task(container_image=image_spec)
193+
def my_task() -> str:
194+
with open("/root/files/input.txt", "r") as f:
195+
return f.read()
196+
```
197+
178198
## Define ImageSpec in a YAML File
179199

180200
You can override the container image by providing an ImageSpec YAML file to the `pyflyte run` or `pyflyte register` command.

0 commit comments

Comments
 (0)