adventurous-forest-12331
01/07/2025, 8:26 PM@TestConfiguration(proxyBeanMethods = false)
class TestContainersConfiguration {
@Bean
@ServiceConnection
fun postgresContainer(): PostgreSQLContainer<*> {
return PostgreSQLContainer(DockerImageName.parse("postgres:16.4"))
}
}
this works fine in docker desktop, but in rancher this doesn't work, I got an exception from flyway dependency of host not found
but if I configure the Postgres container like the following:
companion object {
private val pg = PostgreSQLContainer(DockerImageName.parse("postgres:16.4"))
init {
pg.start()
}
@JvmStatic
@DynamicPropertySource
fun registerDynamicProperties(registry: DynamicPropertyRegistry) {
registry.add("spring.datasource.url", pg::getJdbcUrl)
registry.add("spring.datasource.username", pg::getUsername)
registry.add("spring.datasource.password", pg::getPassword)
}
}
now rancher-desktop works, how can I make it work using the first approach?