diff --git a/bitnami/mongodb/README.md b/bitnami/mongodb/README.md index 7700c25acbf7..b929f1b96c28 100644 --- a/bitnami/mongodb/README.md +++ b/bitnami/mongodb/README.md @@ -144,11 +144,11 @@ The `root` user is configured to have full administrative access to the MongoDB ## Creating a user and database on first run -You can create a user with restricted access to a database while starting the container for the first time. To do this, provide the `MONGODB_USER`, `MONGO_PASSWORD` and `MONGODB_DATABASE` environment variables. +You can create a user with restricted access to a database while starting the container for the first time. To do this, provide the `MONGODB_USERNAME`, `MONGO_PASSWORD` and `MONGODB_DATABASE` environment variables. ```bash docker run --name mongodb \ - -e MONGODB_USER=my_user -e MONGODB_PASSWORD=password123 \ + -e MONGODB_USERNAME=my_user -e MONGODB_PASSWORD=password123 \ -e MONGODB_DATABASE=my_database bitnami/mongodb:latest ``` @@ -158,7 +158,7 @@ or using Docker Compose: mongodb: image: bitnami/mongodb:latest environment: - - MONGODB_USER=my_user + - MONGODB_USERNAME=my_user - MONGODB_PASSWORD=password123 - MONGODB_DATABASE=my_database ``` diff --git a/bitnami/mongodb/rootfs/app-entrypoint.sh b/bitnami/mongodb/rootfs/app-entrypoint.sh index df4393fb4b66..d594b3fbff62 100755 --- a/bitnami/mongodb/rootfs/app-entrypoint.sh +++ b/bitnami/mongodb/rootfs/app-entrypoint.sh @@ -15,7 +15,7 @@ function initialize { # Set default values export MONGODB_ROOT_PASSWORD=${MONGODB_ROOT_PASSWORD:-} -export MONGODB_USER=${MONGODB_USER:-} +export MONGODB_USERNAME=${MONGODB_USERNAME:-} export MONGODB_PASSWORD=${MONGODB_PASSWORD:-} export MONGODB_DATABASE=${MONGODB_DATABASE:-} export MONGODB_REPLICA_SET_MODE=${MONGODB_REPLICA_SET_MODE:-} diff --git a/bitnami/mongodb/rootfs/mongodb-inputs.json b/bitnami/mongodb/rootfs/mongodb-inputs.json index e04185e42599..7c1f56f927c4 100644 --- a/bitnami/mongodb/rootfs/mongodb-inputs.json +++ b/bitnami/mongodb/rootfs/mongodb-inputs.json @@ -1,6 +1,6 @@ { "rootPassword": "{{$global.env.MONGODB_ROOT_PASSWORD}}", - "username": "{{$global.env.MONGODB_USER}}", + "username": "{{$global.env.MONGODB_USERNAME}}", "password": "{{$global.env.MONGODB_PASSWORD}}", "database": "{{$global.env.MONGODB_DATABASE}}", "replicaSetMode": "{{$global.env.MONGODB_REPLICA_SET_MODE}}", diff --git a/bitnami/mongodb/test.sh b/bitnami/mongodb/test.sh index 29cdbdb770dc..8d062acd94d2 100755 --- a/bitnami/mongodb/test.sh +++ b/bitnami/mongodb/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bats MONGODB_DATABASE=test_database -MONGODB_USER=test_user +MONGODB_USERNAME=test_user MONGODB_PASSWORD=test_password # source the helper script @@ -71,44 +71,44 @@ cleanup_environment @test "Can't create custom user without a password" { run container_create default \ - -e MONGODB_USER=$MONGODB_USER + -e MONGODB_USERNAME=$MONGODB_USERNAME [[ "$output" =~ "If you defined an username you must define a password and a database too" ]] } @test "Can't create custom user without database" { run container_create default \ - -e MONGODB_USER=$MONGODB_USER \ + -e MONGODB_USERNAME=$MONGODB_USERNAME \ -e MONGODB_PASSWORD=$MONGODB_PASSWORD \ [[ "$output" =~ "If you defined an username you must define a password and a database too" ]] } @test "Custom user created with password" { container_create default -d \ - -e MONGODB_USER=$MONGODB_USER \ + -e MONGODB_USERNAME=$MONGODB_USERNAME \ -e MONGODB_PASSWORD=$MONGODB_PASSWORD \ -e MONGODB_DATABASE=$MONGODB_DATABASE - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" [[ "$output" =~ '"ok" : 1' ]] - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" [[ "$output" =~ '"users"' ]] } @test "Custom user can't access admin database" { container_create default -d \ - -e MONGODB_USER=$MONGODB_USER \ + -e MONGODB_USERNAME=$MONGODB_USERNAME \ -e MONGODB_PASSWORD=$MONGODB_PASSWORD \ -e MONGODB_DATABASE=$MONGODB_DATABASE - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD admin --eval "printjson(db.adminCommand('listDatabases'))" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD admin --eval "printjson(db.adminCommand('listDatabases'))" [[ "$output" =~ "login failed" ]] } @test "Can set root password and create custom user" { container_create default -d \ -e MONGODB_ROOT_PASSWORD=$MONGODB_PASSWORD \ - -e MONGODB_USER=$MONGODB_USER \ + -e MONGODB_USERNAME=$MONGODB_USERNAME \ -e MONGODB_PASSWORD=$MONGODB_PASSWORD \ -e MONGODB_DATABASE=$MONGODB_DATABASE @@ -116,25 +116,25 @@ cleanup_environment [[ "$output" =~ '"ok" : 1' ]] [[ "$output" =~ '"name" : "admin"' ]] - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" [[ "$output" =~ '"ok" : 1' ]] - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" [[ "$output" =~ '"users"' ]] } @test "Settings and data are preserved on container restart" { container_create default -d \ - -e MONGODB_USER=$MONGODB_USER \ + -e MONGODB_USERNAME=$MONGODB_USERNAME \ -e MONGODB_PASSWORD=$MONGODB_PASSWORD \ -e MONGODB_DATABASE=$MONGODB_DATABASE - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" [[ "$output" =~ '"ok" : 1' ]] container_restart default - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" [[ "$output" =~ '"users"' ]] } @@ -156,17 +156,17 @@ cleanup_environment @test "If host mounted, setting and data are preserved after deletion" { container_create_with_host_volumes default -d \ - -e MONGODB_USER=$MONGODB_USER \ + -e MONGODB_USERNAME=$MONGODB_USERNAME \ -e MONGODB_PASSWORD=$MONGODB_PASSWORD \ -e MONGODB_DATABASE=$MONGODB_DATABASE - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.createCollection('users'))" [[ "$output" =~ '"ok" : 1' ]] container_remove default container_create_with_host_volumes default -d - run mongo_client default -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" + run mongo_client default -u $MONGODB_USERNAME -p $MONGODB_PASSWORD $MONGODB_DATABASE --eval "printjson(db.getCollectionNames())" [[ "$output" =~ '"users"' ]] }