diff --git a/modules/r2dbc/src/main/java/org/testcontainers/r2dbc/R2DBCDatabaseContainerProvider.java b/modules/r2dbc/src/main/java/org/testcontainers/r2dbc/R2DBCDatabaseContainerProvider.java index 9d3efc17ac7..ded7aaa9ffd 100644 --- a/modules/r2dbc/src/main/java/org/testcontainers/r2dbc/R2DBCDatabaseContainerProvider.java +++ b/modules/r2dbc/src/main/java/org/testcontainers/r2dbc/R2DBCDatabaseContainerProvider.java @@ -5,6 +5,7 @@ import io.r2dbc.spi.ConnectionFactoryMetadata; import io.r2dbc.spi.ConnectionFactoryOptions; import io.r2dbc.spi.Option; +import org.testcontainers.DockerClientFactory; import javax.annotation.Nullable; @@ -21,7 +22,7 @@ public interface R2DBCDatabaseContainerProvider { default ConnectionFactoryMetadata getMetadata(ConnectionFactoryOptions options) { ConnectionFactoryOptions.Builder builder = options.mutate(); if (!options.hasOption(ConnectionFactoryOptions.HOST)) { - builder.option(ConnectionFactoryOptions.HOST, "localhost"); + builder.option(ConnectionFactoryOptions.HOST, DockerClientFactory.instance().dockerHostIpAddress()); } if (!options.hasOption(ConnectionFactoryOptions.PORT)) { builder.option(ConnectionFactoryOptions.PORT, 65535);