Hello!
I've created a simple rule using GenericContainer:
@ClassRule
public static GenericContainer postgres = new GenericContainer("localhost:5000/postgres:10.2")
.withExposedPorts(5432)
.withEnv("POSTGRES_DB", "ib")
.withEnv("POSTGRES_USER", "postgres")
.withEnv("POSTGRES_PASSWORD", "admin")
.withClasspathResourceMapping("init.sql", "/docker-entrypoint-initdb.d/init.sql", BindMode.READ_ONLY);
But I've got an error during container creation:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: 2018-04-28 08:05:33.605 UTC [61] LOG: database system is ready to accept connections
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: done
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: server started
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: CREATE DATABASE
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: ALTER ROLE
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDERR: psql:/docker-entrypoint-initdb.d/init.sql:0: could not read from input file: Is a directory
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 65.473 sec <<< FAILURE!
SimplePostgreSQLTest Time elapsed: 65.466 sec <<< ERROR!
Can't realise what I'm doing wrong. Any help is appreciated.
Update
After inspecting the container's contents I've found that init.sql is mapped as a directory, not a file.
How to map a file then?
Hello!
I've created a simple rule using GenericContainer:
@ClassRule
public static GenericContainer postgres = new GenericContainer("localhost:5000/postgres:10.2")
.withExposedPorts(5432)
.withEnv("POSTGRES_DB", "ib")
.withEnv("POSTGRES_USER", "postgres")
.withEnv("POSTGRES_PASSWORD", "admin")
.withClasspathResourceMapping("init.sql", "/docker-entrypoint-initdb.d/init.sql", BindMode.READ_ONLY);
But I've got an error during container creation:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: 2018-04-28 08:05:33.605 UTC [61] LOG: database system is ready to accept connections
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: done
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: server started
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: CREATE DATABASE
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: ALTER ROLE
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT:
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDOUT: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
[testcontainers-netty-1-6] INFO 🐳 [localhost:5000/postgres:10.2] - STDERR: psql:/docker-entrypoint-initdb.d/init.sql:0: could not read from input file: Is a directory
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 65.473 sec <<< FAILURE!
SimplePostgreSQLTest Time elapsed: 65.466 sec <<< ERROR!
Can't realise what I'm doing wrong. Any help is appreciated.
Update
After inspecting the container's contents I've found that init.sql is mapped as a directory, not a file.
How to map a file then?