testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

Support MountableFile when build by GraalVM as native-build

Open bedla opened this issue 2 months ago • 0 comments

Hi, I found out that, when I run Testcontainers using GraalVM native build and I want to have support for MountableFile from class path, it fails with following exception. I was digging deeper and find out that it is because resources loaded using class-loader have "non-standard" File path with prefix resource: and that's why it cannot be mounted with usual code already presented in TC. What I found out is that resource should be extracted to temp directory as we already do with .jar resources, and then mounted as usual. I would like to write tests for this, but GraalVM is needed to make it reproducible. Do you have somewhere tests for GraalVM to point me to for inspiration? What do you think about this change? Thank you Ivos


Problem with mounting-supported-check in methow org.testcontainers.DockerClientFactory#checkMountableFile

Exception in thread "main" com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: mount denied: the source path "resource:/org/example/Main.class:/dummy:ro" too many colons

        at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:247)
        at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.post(DefaultInvocationBuilder.java:124)
        at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:37)
        at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:13)
        at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
        at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:33)
        at org.testcontainers.shaded.com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:608)
        at org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:364)
        at org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:351)
        at org.example.Main.checkMountableFile(Main.java:53)
        at org.example.Main.main(Main.java:37)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

bedla avatar Sep 28 '25 18:09 bedla