<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-postgresql</artifactId>
<scope>test</scope>
</dependency>-
embedded.postgresql.enabled(true|false, default is true) -
embedded.postgresql.reuseContainer(true|false, default is false) -
embedded.postgresql.dockerImage(default is 'postgres:17-alpine')-
Image versions on dockerhub
-
-
embedded.postgresql.waitTimeoutInSeconds(default is 60 seconds) -
embedded.postgresql.database -
embedded.postgresql.user -
embedded.postgresql.password -
embedded.postgresql.initScriptPath(default is null) -
embedded.postgresql.startupLogCheckRegex(default is null) -
embedded.postgresql.mountVolumes(default is empty list) -
embedded.toxiproxy.proxies.postgresql.enabledEnables both creation of the container with ToxiProxy TCP proxy and a proxy to theembedded-postgresqlcontainer.
-
embedded.postgresql.port -
embedded.postgresql.host -
embedded.postgresql.schema -
embedded.postgresql.user -
embedded.postgresql.password -
embedded.postgresql.toxiproxy.host -
embedded.postgresql.toxiproxy.port -
embedded.postgresql.networkAlias -
embedded.postgresql.internalPort -
Bean
ToxiproxyContainer.ContainerProxy postgresqlContainerProxy
bootstrap-test.yml
embedded:
postgresql:
enabled: true
docker-image: 'postgres:16-alpine'
wait-timeout-in-seconds: 40
command: '/opt/bitnami/scripts/postgresql/run.sh'
startupLogCheckRegex: '.*database system is ready to accept connections.*'
mountVolumes:
-
hostPath: 'pgdata' # local directory to store database files
containerPath: '/bitnami/postgresql' # /var/lib/postgresql/data for https://hub.docker.com/_/postgres
mode: READ_WRITE # persist data locally between container restarts
-
hostPath: 'src/main/resources/my-postgresql.conf' # local file
containerPath: '/bitnami/postgresql/conf/postgresql.conf' # /etc/postgresql/postgresql.conf for https://hub.docker.com/_/postgres
mode: READ_ONLY # prevent container from changing file contents (default)application-test.yml
spring:
datasource:
url: "jdbc:postgresql://${embedded.postgresql.host}:${embedded.postgresql.port}/${embedded.postgresql.schema}"
username: ${embedded.postgresql.user}
password: ${embedded.postgresql.password}