diff --git a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoEnvironment.java b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoEnvironment.java index 7bdb2e407b0a..1129d09cb11b 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoEnvironment.java +++ b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoEnvironment.java @@ -41,9 +41,9 @@ class MongoEnvironment { "MONGO_INITDB_ROOT_USERNAME_FILE is not supported"); Assert.state(!env.containsKey("MONGO_INITDB_ROOT_PASSWORD_FILE"), "MONGO_INITDB_ROOT_PASSWORD_FILE is not supported"); - this.username = env.getOrDefault("MONGO_INITDB_ROOT_USERNAME", env.get("MONGO_ROOT_USERNAME")); - this.password = env.getOrDefault("MONGO_INITDB_ROOT_PASSWORD", env.get("MONGO_ROOT_PASSWORD")); - this.database = env.get("MONGO_INITDB_DATABASE"); + this.username = env.getOrDefault("MONGO_INITDB_ROOT_USERNAME", env.get("MONGODB_ROOT_USERNAME")); + this.password = env.getOrDefault("MONGO_INITDB_ROOT_PASSWORD", env.get("MONGODB_ROOT_PASSWORD")); + this.database = env.getOrDefault("MONGO_INITDB_DATABASE", env.get("MONGODB_DATABASE")); } String getUsername() { diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoBitnamiDockerComposeConnectionDetailsFactoryIntegrationTests.java b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoBitnamiDockerComposeConnectionDetailsFactoryIntegrationTests.java index ce9a8b4e6acd..ac3daf4b9535 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoBitnamiDockerComposeConnectionDetailsFactoryIntegrationTests.java +++ b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoBitnamiDockerComposeConnectionDetailsFactoryIntegrationTests.java @@ -46,7 +46,7 @@ void runCreatesConnectionDetails() { assertThat(connectionString.getCredential().getUserName()).isEqualTo("root"); assertThat(connectionString.getCredential().getPassword()).isEqualTo("secret".toCharArray()); assertThat(connectionString.getCredential().getSource()).isEqualTo("admin"); - assertThat(connectionString.getDatabase()).isEqualTo("test"); + assertThat(connectionString.getDatabase()).isEqualTo("testdb"); assertThat(connectionDetails.getGridFs()).isNull(); } diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/mongo/mongo-bitnami-compose.yaml b/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/mongo/mongo-bitnami-compose.yaml index 0a09b5ced4f6..1b2f92a8585c 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/mongo/mongo-bitnami-compose.yaml +++ b/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/mongo/mongo-bitnami-compose.yaml @@ -4,5 +4,6 @@ services: ports: - '27017' environment: - - 'MONGO_ROOT_USERNAME=root' - - 'MONGO_ROOT_PASSWORD=secret' + - 'MONGODB_ROOT_USERNAME=root' + - 'MONGODB_ROOT_PASSWORD=secret' + - 'MONGODB_DATABASE=testdb'