This can be reproduced using Petclinic's tests with AOT enabled:
tasks.named('test') {
  useJUnitPlatform()
  systemProperty "spring.aot.enabled", true
}
./gradlew test fails with both tests in PostgresIntegrationTests failing as they could not connect to Postgres. They try to use the default host and port rather than those of a container starter by Docker Compose.