-
|
I have an initial script like this. It worked well when using But when I create a Postgres docker container using testcontainers like this. It will fail with the following exception. The example project to reproduce this issue: https://github.com/hantsy/spring6-sandbox/blob/master/jdbc/src/test/java/com/example/demo/testcontainers/PostRepositoryTestWithTestcontainers.java |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Hey @hantsy, this is related to this issue: The best solution is to delegate the script execution to Postgres itself. This can be achieved by copying the file into a special location in the container (a feature of the Postgres image): new PostgreSQLContainer("postgres:12")
.withCopyFileToContainer(
MountableFile.forClasspathResource("init.sql"),
"/docker-entrypoint-initdb.d/init.sql"
); |
Beta Was this translation helpful? Give feedback.
Hey @hantsy, this is related to this issue:
#4441
The best solution is to delegate the script execution to Postgres itself. This can be achieved by copying the file into a special location in the container (a feature of the Postgres image):