Sign inSign up

ifloor/bt-mongodb

By ifloor

•Updated 12 months ago

safe port of bitnami mongodb

Image
0

2.8K

ifloor/bt-mongodb repository overview

For the full file, look for: mongo_README.md, on kb-files

⁠MongoDB® packaged by Bitnami

⁠What is MongoDB®?

MongoDB® is a relational open source NoSQL database. Easy to use, it stores data in JSON-like documents. Automated scalability and high-performance. Ideal for developing cloud native applications.

Overview of MongoDB®⁠ Disclaimer: The respective trademarks mentioned in the offering are owned by the respective companies. We do not provide a commercial license for any of these products. This listing has an open-source license. MongoDB(R) is run and maintained by MongoDB, which is a completely separate project from Bitnami.

⁠TL;DR

docker run --name mongodb bitnami/mongodb:latest

⁠⚠️ Important Notice: Upcoming changes to the Bitnami Catalog

Beginning August 28th, 2025, Bitnami will evolve its public catalog to offer a curated set of hardened, security-focused images under the new Bitnami Secure Images initiative⁠. As part of this transition:

  • Granting community users access for the first time to security-optimized versions of popular container images.
  • Bitnami will begin deprecating support for non-hardened, Debian-based software images in its free tier and will gradually remove non-latest tags from the public catalog. As a result, community users will have access to a reduced number of hardened images. These images are published only under the “latest” tag and are intended for development purposes
  • Starting August 28th, over two weeks, all existing container images, including older or versioned tags (e.g., 2.50.0, 10.6), will be migrated from the public catalog (docker.io/bitnami) to the “Bitnami Legacy” repository (docker.io/bitnamilegacy), where they will no longer receive updates.
  • For production workloads and long-term support, users are encouraged to adopt Bitnami Secure Images, which include hardened containers, smaller attack surfaces, CVE transparency (via VEX/KEV), SBOMs, and enterprise support.

These changes aim to improve the security posture of all Bitnami users by promoting best practices for software supply chain integrity and up-to-date deployments. For more details, visit the Bitnami Secure Images announcement⁠.

⁠Why use Bitnami Secure Images?

  • Bitnami Secure Images and Helm charts are built to make open source more secure and enterprise ready.
  • Triage security vulnerabilities faster, with transparency into CVE risks using industry standard Vulnerability Exploitability Exchange (VEX), KEV, and EPSS scores.
  • Our hardened images use a minimal OS (Photon Linux), which reduces the attack surface while maintaining extensibility through the use of an industry standard package format.
  • Stay more secure and compliant with continuously built images updated within hours of upstream patches.
  • Bitnami containers, virtual machines and cloud images use the same components and configuration approach - making it easy to switch between formats based on your project needs.
  • Hardened images come with attestation signatures (Notation), SBOMs, virus scan reports and other metadata produced in an SLSA-3 compliant software factory.

Only a subset of BSI applications are available for free. Looking to access the entire catalog of applications as well as enterprise support? Try the commercial edition of Bitnami Secure Images today⁠.

⁠How to deploy MongoDB® in Kubernetes?

Deploying Bitnami applications as Helm Charts is the easiest way to get started with our applications on Kubernetes. Read more about the installation in the Bitnami MongoDB® Chart GitHub repository⁠.

⁠Why use a non-root container?

Non-root container images add an extra layer of security and are generally recommended for production environments. However, because they run as a non-root user, privileged tasks are typically off-limits. Learn more about non-root containers in our docs⁠.

Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags in our documentation page⁠.

You can see the equivalence between the different tags by taking a look at the tags-info.yaml file present in the branch folder, i.e bitnami/ASSET/BRANCH/DISTRO/tags-info.yaml.

Subscribe to project updates by watching the bitnami/containers GitHub repo⁠.

⁠Get this image

The recommended way to get the Bitnami MongoDB® Docker Image is to pull the prebuilt image from the Docker Hub Registry⁠.

docker pull bitnami/mongodb:latest

To use a specific version, you can pull a versioned tag. You can view the list of available versions⁠ in the Docker Hub Registry.

docker pull bitnami/mongodb:[TAG]

If you wish, you can also build the image yourself by cloning the repository, changing to the directory containing the Dockerfile and executing the docker build command. Remember to replace the APP, VERSION and OPERATING-SYSTEM path placeholders in the example command below with the correct values.

git clone https://github.com/bitnami/containers.git
cd bitnami/APP/VERSION/OPERATING-SYSTEM
docker build -t bitnami/APP:latest .

⁠Persisting your database

If you remove the container all your data will be lost, and the next time you run the image the database will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.

For persistence you should mount a directory at the /bitnami/mongodb path. If the mounted directory is empty, it will be initialized on the first run.

docker run \
    -v /path/to/mongodb-persistence:/bitnami/mongodb \
    bitnami/mongodb:latest

or by modifying the docker-compose.yml⁠ file present in this repository:

 ...
 services:
   mongodb:
     ...
     volumes:
-      - mongodb_data:/bitnami/mongodb
+      - /path/to/mongodb-persistence:/bitnami/mongodb
   ...

NOTE: As this is a non-root container, the mounted files and directories must have the proper permissions for the UID 1001.

⁠Connecting to other containers

Using Docker container networking⁠, a MongoDB® server running inside a container can easily be accessed by your application containers.

Containers attached to the same network can communicate with each other using the container name as the hostname.

⁠Using the Command Line

In this example, we will create a MongoDB® client instance that will connect to the server instance that is running on the same docker network as the client.

⁠Step 1: Create a network
docker network create app-tier --driver bridge
⁠Step 2: Launch the MongoDB® server instance

Use the --network app-tier argument to the docker run command to attach the MongoDB® container to the app-tier network.

docker run -d --name mongodb-server \
    --network app-tier \
    bitnami/mongodb:latest
⁠Step 3: Launch your MongoDB® client instance

Finally we create a new container instance to launch the MongoDB® client and connect to the server created in the previous step:

docker run -it --rm \
    --network app-tier \
    bitnami/mongodb:latest mongo --host mongodb-server
⁠Using a Docker Compose file

When not specified, Docker Compose automatically sets up a new network and attaches all deployed services to that network. However, we will explicitly define a new bridge network named app-tier. In this example we assume that you want to connect to the MongoDB® server from your own custom application image which is identified in the following snippet by the service name myapp.

version: '2'

networks:
  app-tier:
    driver: bridge

services:
  mongodb:
    image: bitnami/mongodb:latest
    networks:
      - app-tier
  myapp:
    image: YOUR_APPLICATION_IMAGE
    networks:
      - app-tier

IMPORTANT:

  1. Please update the YOUR_APPLICATION_IMAGE_ placeholder in the above snippet with your application image
  2. In your application container, use the hostname mongodb to connect to the MongoDB® server

Launch the containers using:

docker-compose up -d

⁠Configuration

⁠Environment variables
⁠Customizable environment variables
NameDescriptionDefault Value
MONGODB_MOUNTED_CONF_DIRDirectory for including custom configuration files (that override the default generated ones)${MONGODB_VOLUME_DIR}/conf
MONGODB_INIT_RETRY_ATTEMPTSMaximum retries for checking the service initialization status7
MONGODB_INIT_RETRY_DELAYTime (in seconds) to wait between retries for checking the service initialization status5
MONGODB_PORT_NUMBERMongoDB port$MONGODB_DEFAULT_PORT_NUMBER
MONGODB_EXTRA_FLAGSExtra flags for MongoDB initializationnil
MONGODB_ENABLE_NUMACTLExecute commands using numactlfalse
MONGODB_SHELL_EXTRA_FLAGSExtra flags when using the mongodb client during initialization (useful when mounting init scripts)nil
MONGODB_ADVERTISED_HOSTNAMEHostname to use for advertising the MongoDB servicenil
MONGODB_ADVERTISE_IPWhether advertised hostname is set to container ipfalse
MONGODB_ADVERTISED_PORT_NUMBERMongoDB advertised port number. It is recommended to pass this environment variable if you have a proxy port forwarding requests to container.nil
MONGODB_DISABLE_JAVASCRIPTDisable MongoDB server-side javascript executionno
MONGODB_ENABLE_JOURNALEnable MongoDB journalnil
MONGODB_DISABLE_SYSTEM_LOGDisable MongoDB daemon system lognil
MONGODB_ENABLE_DIRECTORY_PER_DBUse a separate folder for storing each database datanil
MONGODB_ENABLE_IPV6Use IPv6 for database connectionsnil
MONGODB_SYSTEM_LOG_VERBOSITYMongoDB daemon log levelnil
MONGODB_ROOT_USERUser name for the MongoDB root userroot
MONGODB_ROOT_PASSWORDPassword for the MongoDB root usernil
MONGODB_USERNAMEUser to generate at initialization timenil
MONGODB_PASSWORDPassword for the non-root user specified in MONGODB_USERNAMEnil
MONGODB_DATABASEName of the database to create at initialization timenil
MONGODB_METRICS_USERNAMEUser used for metrics collection, for example with mongodb_exporternil
MONGODB_METRICS_PASSWORDPassword for the non-root user specified in MONGODB_METRICS_USERNAMEnil
MONGODB_EXTRA_USERNAMESComma or semicolon separated list of extra users to be created.nil
MONGODB_EXTRA_PASSWORDSComma or semicolon separated list of passwords for the users specified in MONGODB_EXTRA_USERNAMES.nil
MONGODB_EXTRA_DATABASESComma or semicolon separated list of databases to create at initialization time for the users specified in MONGODB_EXTRA_USERNAMES.nil
ALLOW_EMPTY_PASSWORDPermit accessing MongoDB without setting any passwordno
MONGODB_REPLICA_SET_MODEMongoDB replica set mode. Can be one of primary, secondary or arbiternil
MONGODB_REPLICA_SET_NAMEName of the MongoDB replica set$MONGODB_DEFAULT_REPLICA_SET_NAME
MONGODB_REPLICA_SET_KEYMongoDB replica set keynil
MONGODB_INITIAL_PRIMARY_HOSTHostname of the replica set primary node (necessary for arbiter and secondary nodes)nil
MONGODB_INITIAL_PRIMARY_PORT_NUMBERPort of the replica set primary node (necessary for arbiter and secondary nodes)27017
MONGODB_INITIAL_PRIMARY_ROOT_PASSWORDPrimary node root user password (necessary for arbiter and secondary nodes)nil
MONGODB_INITIAL_PRIMARY_ROOT_USERPrimary node root username (necessary for arbiter and secondary nodes)root
MONGODB_SET_SECONDARY_OKMark node as readable. Necessary for cases where the PVC is lostno
MONGODB_DISABLE_ENFORCE_AUTHBy default, MongoDB authentication will be enforced. If set to true, MongoDB will not enforce authenticationfalse
⁠Read-only environment variables
NameDescriptionValue
MONGODB_VOLUME_DIRPersistence base directory$BITNAMI_VOLUME_DIR/mongodb
MONGODB_BASE_DIRMongoDB installation directory$BITNAMI_ROOT_DIR/mongodb
MONGODB_CONF_DIRMongoDB configuration directory$MONGODB_BASE_DIR/conf
MONGODB_DEFAULT_CONF_DIRMongoDB default configuration directory$MONGODB_BASE_DIR/conf.default
MONGODB_LOG_DIRMongoDB logs directory$MONGODB_BASE_DIR/logs
MONGODB_DATA_DIRMongoDB data directory${MONGODB_VOLUME_DIR}/data
MONGODB_TMP_DIRMongoDB temporary directory$MONGODB_BASE_DIR/tmp
MONGODB_BIN_DIRMongoDB executables directory$MONGODB_BASE_DIR/bin
MONGODB_TEMPLATES_DIRDirectory where the mongodb.conf template file is stored$MONGODB_BASE_DIR/templates
MONGODB_MONGOD_TEMPLATES_FILEPath to the mongodb.conf template file$MONGODB_TEMPLATES_DIR/mongodb.conf.tpl
MONGODB_CONF_FILEPath to MongoDB configuration file$MONGODB_CONF_DIR/mongodb.conf
MONGODB_KEY_FILEPath to the MongoDB replica set keyfile$MONGODB_CONF_DIR/keyfile
MONGODB_DB_SHELL_FILEPath to MongoDB dbshell file/.dbshell
MONGODB_RC_FILEPath to MongoDB rc file/.mongorc.js
MONGOSH_DIRPath to mongosh directory/.mongodb
MONGOSH_RC_FILEPath to mongosh rc file/.mongoshrc.js
MONGODB_PID_FILEPath to the MongoDB PID file$MONGODB_TMP_DIR/mongodb.pid
MONGODB_LOG_FILEPath to the MongoDB log file$MONGODB_LOG_DIR/mongodb.log
MONGODB_INITSCRIPTS_DIRPath to the MongoDB container init scripts directory/docker-entrypoint-initdb.d
MONGODB_DAEMON_USERMongoDB system usermongo
MONGODB_DAEMON_GROUPMongoDB system groupmongo
MONGODB_DEFAULT_PORT_NUMBERMongoDB port set at build time27017
MONGODB_DEFAULT_ENABLE_JOURNALEnable MongoDB journal at build timetrue
MONGODB_DEFAULT_DISABLE_SYSTEM_LOGDisable MongoDB daemon system log set at build timefalse
MONGODB_DEFAULT_ENABLE_DIRECTORY_PER_DBUse a separate folder for storing each database data set at build timefalse
MONGODB_DEFAULT_ENABLE_IPV6Use IPv6 for database connections set at build timefalse
MONGODB_DEFAULT_SYSTEM_LOG_VERBOSITYMongoDB daemon log level set at build time0
MONGODB_DEFAULT_REPLICA_SET_NAMEName of the MongoDB replica set at build timereplicaset
⁠Initializing a new instance

When the container is executed for the first time, it will execute the files with extensions .sh, and .js located at /docker-entrypoint-initdb.d.

In order to have your custom files inside the docker image you can mount them as a volume.

⁠Passing extra command-line flags to mongod startup

Passing extra command-line flags to the mongod service command is possible through the following env var:

  • MONGODB_EXTRA_FLAGS: Flags to be appended to the mongod startup command. No defaults
  • MONGODB_CLIENT_EXTRA_FLAGS: Flags to be appended to the mongo command which is used to connect to the (local or remote) mongod daemon. No defaults
docker run --name mongodb -e ALLOW_EMPTY_PASSWORD=yes -e MONGODB_EXTRA_FLAGS='--wiredTigerCacheSizeGB=2' bitnami/mongodb:latest

or by modifying the docker-compose.yml⁠ file present in this repository:

services:
  mongodb:
  ...
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MONGODB_EXTRA_FLAGS=--wiredTigerCacheSizeGB=2
  ...
⁠Configuring system log verbosity level

Configuring the system log verbosity level is possible through the following env vars:

  • MONGODB_DISABLE_SYSTEM_LOG: Whether to enable/disable system log on MongoDB®. Default: false. Possible values: [true, false].
  • MONGODB_SYSTEM_LOG_VERBOSITY: MongoDB® system log verbosity level. Default: 0. Possible values: [0, 1, 2, 3, 4, 5]. For more information about the verbosity levels please refer to the MongoDB® documentation⁠
docker run --name mongodb -e ALLOW_EMPTY_PASSWORD=yes -e MONGODB_SYSTEM_LOG_VERBOSITY='3' bitnami/mongodb:latest

or by modifying the docker-compose.yml⁠ file present in this repository:

services:
  mongodb:
  ...
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MONGODB_SYSTEM_LOG_VERBOSITY=3
  ...

Tag summary

Content type

Image

Digest

sha256:4f0f02860…

Size

266.1 MB

Last updated

12 months ago

docker pull ifloor/bt-mongodb:8.0-debian-12