Back to Testcontainers Java

Files and volumes

docs/features/files.md

2.0.51.2 KB
Original Source

Files and volumes

Copying files

Files can be copied into the container before startup, or can be copied from the container after the container has started.

!!! note This is the recommended approach for portability cross-docker environments.

Copying to a container before startup

<!--codeinclude-->

Copying files using MountableFile inside_block:copyToContainer

<!--/codeinclude-->

Using Transferable, file content will be placed in the specified location.

<!--codeinclude-->

Copying files using Transferable inside_block:transferableFile

<!--/codeinclude-->

Setting file mode is also possible.

<!--codeinclude-->

Copying files using Transferable with file mode inside_block:transferableWithFileMode

<!--/codeinclude-->

Copying a file from a running container

<!--codeinclude-->

Copying files from a container inside_block:copyFileFromContainer

<!--/codeinclude-->