I use TestContainers for my integration tests. Currently, I use withCopyFileToContainer(MountableFile.forClassPathResource(...))
to copy some files from the host to a test container when starting the test container (so the service in which the tests reside is packaged in a jar
and run locally on the host and the jar
itself contains some files which need to be copied to the test containers which are started from the tests). This does not work when the service itself which contains the tests is containerized (so the jar
file containing the files is started in a container, has access to the host docker via the docker socket, and starts new test containers to which some files need to be copied). I assume Test Containers is not able to copy a file from a container to another container. What would be the solution?
- Should I implement the
Transferable
interface and provide an implementation for thetransferTo
method? - Should I use some kind of volumes? Any ideas are welcome.