bitnami/mongodbMongoDB® 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.
consoledocker run --name mongodb bitnami/mongodb:latest
Those are hardened, minimal CVE images built and maintained by Bitnami. Bitnami Secure Images are based on the cloud-optimized, security-hardened enterprise OS Photon Linux. Why choose BSI images?
Each image comes with valuable security metadata. You can view the metadata in our public catalog here. Note: Some data is only available with commercial subscriptions to BSI.
!Alt text !Alt text
If you are looking for our previous generation of images based on Debian Linux, please see the Bitnami Legacy registry.
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.
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.
Dockerfile linksLearn 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.
The recommended way to get the Bitnami MongoDB® Docker Image is to pull the prebuilt image from the Docker Hub Registry.
consoledocker 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.
consoledocker 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.
consolegit clone [***] cd bitnami/APP/VERSION/OPERATING-SYSTEM docker build -t bitnami/APP:latest .
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.
consoledocker run \ -v /path/to/mongodb-persistence:/bitnami/mongodb \ bitnami/mongodb:latest
or by modifying the docker-compose.yml file present in this repository:
diff... 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.
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.
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.
consoledocker network create app-tier --driver bridge
Use the --network app-tier argument to the docker run command to attach the MongoDB® container to the app-tier network.
consoledocker run -d --name mongodb-server \ --network app-tier \ bitnami/mongodb:latest
Finally we create a new container instance to launch the MongoDB® client and connect to the server created in the previous step:
consoledocker run -it --rm \ --network app-tier \ bitnami/mongodb:latest mongo --host mongodb-server
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.
yamlversion: '2' networks: app-tier: driver: bridge services: mongodb: image: bitnami/mongodb:latest networks: - app-tier myapp: image: YOUR_APPLICATION_IMAGE networks: - app-tier
IMPORTANT:
- Please update the YOUR_APPLICATION_IMAGE_ placeholder in the above snippet with your application image
- In your application container, use the hostname
mongodbto connect to the MongoDB® server
Launch the containers using:
consoledocker-compose up -d
| Name | Description | Default Value |
|---|---|---|
MONGODB_MOUNTED_CONF_DIR | Directory for including custom configuration files (that override the default generated ones) | ${MONGODB_VOLUME_DIR}/conf |
MONGODB_INIT_RETRY_ATTEMPTS | Maximum retries for checking the service initialization status | 7 |
MONGODB_INIT_RETRY_DELAY | Time (in seconds) to wait between retries for checking the service initialization status | 5 |
MONGODB_PORT_NUMBER | MongoDB port | $MONGODB_DEFAULT_PORT_NUMBER |
MONGODB_EXTRA_FLAGS | Extra flags for MongoDB initialization | nil |
MONGODB_ENABLE_NUMACTL | Execute commands using numactl | false |
MONGODB_SHELL_EXTRA_FLAGS | Extra flags when using the mongodb client during initialization (useful when mounting init scripts) | nil |
MONGODB_ADVERTISED_HOSTNAME | Hostname to use for advertising the MongoDB service | nil |
MONGODB_ADVERTISE_IP | Whether advertised hostname is set to container ip | false |
MONGODB_ADVERTISED_PORT_NUMBER | MongoDB advertised port number. It is recommended to pass this environment variable if you have a proxy port forwarding requests to container. | nil |
MONGODB_DISABLE_JAVASCRIPT | Disable MongoDB server-side javascript execution | no |
MONGODB_ENABLE_JOURNAL | Enable MongoDB journal | nil |
MONGODB_DISABLE_SYSTEM_LOG | Disable MongoDB daemon system log | nil |
MONGODB_ENABLE_DIRECTORY_PER_DB | Use a separate folder for storing each database data | nil |
MONGODB_ENABLE_IPV6 | Use IPv6 for database connections | nil |
MONGODB_SYSTEM_LOG_VERBOSITY | MongoDB daemon log level | nil |
MONGODB_ROOT_USER | User name for the MongoDB root user | root |
MONGODB_ROOT_PASSWORD | Password for the MongoDB root user | nil |
MONGODB_USERNAME | User to generate at initialization time | nil |
MONGODB_PASSWORD | Password for the non-root user specified in MONGODB_USERNAME | nil |
MONGODB_DATABASE | Name of the database to create at initialization time | nil |
MONGODB_METRICS_USERNAME | User used for metrics collection, for example with mongodb_exporter | nil |
MONGODB_METRICS_PASSWORD | Password for the non-root user specified in MONGODB_METRICS_USERNAME | nil |
MONGODB_EXTRA_USERNAMES | Comma or semicolon separated list of extra users to be created. | nil |
MONGODB_EXTRA_PASSWORDS | Comma or semicolon separated list of passwords for the users specified in MONGODB_EXTRA_USERNAMES. | nil |
MONGODB_EXTRA_DATABASES | Comma or semicolon separated list of databases to create at initialization time for the users specified in MONGODB_EXTRA_USERNAMES. | nil |
ALLOW_EMPTY_PASSWORD | Permit accessing MongoDB without setting any password | no |
MONGODB_REPLICA_SET_MODE | MongoDB replica set mode. Can be one of primary, secondary or arbiter | nil |
MONGODB_REPLICA_SET_NAME | Name of the MongoDB replica set | $MONGODB_DEFAULT_REPLICA_SET_NAME |
MONGODB_REPLICA_SET_KEY | MongoDB replica set key | nil |
MONGODB_INITIAL_PRIMARY_HOST | Hostname of the replica set primary node (necessary for arbiter and secondary nodes) | nil |
MONGODB_INITIAL_PRIMARY_PORT_NUMBER | Port of the replica set primary node (necessary for arbiter and secondary nodes) | 27017 |
MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD | Primary node root user password (necessary for arbiter and secondary nodes) | nil |
MONGODB_INITIAL_PRIMARY_ROOT_USER | Primary node root username (necessary for arbiter and secondary nodes) | root |
MONGODB_SET_SECONDARY_OK | Mark node as readable. Necessary for cases where the PVC is lost | no |
MONGODB_DISABLE_ENFORCE_AUTH | By default, MongoDB authentication will be enforced. If set to true, MongoDB will not enforce authentication | false |
| Name | Description | Value |
|---|---|---|
MONGODB_VOLUME_DIR | Persistence base directory | $BITNAMI_VOLUME_DIR/mongodb |
MONGODB_BASE_DIR | MongoDB installation directory | $BITNAMI_ROOT_DIR/mongodb |
MONGODB_CONF_DIR | MongoDB configuration directory | $MONGODB_BASE_DIR/conf |
MONGODB_DEFAULT_CONF_DIR | MongoDB default configuration directory | $MONGODB_BASE_DIR/conf.default |
MONGODB_LOG_DIR | MongoDB logs directory | $MONGODB_BASE_DIR/logs |
MONGODB_DATA_DIR | MongoDB data directory | ${MONGODB_VOLUME_DIR}/data |
MONGODB_TMP_DIR | MongoDB temporary directory | $MONGODB_BASE_DIR/tmp |
MONGODB_BIN_DIR | MongoDB executables directory | $MONGODB_BASE_DIR/bin |
MONGODB_TEMPLATES_DIR | Directory where the mongodb.conf template file is stored | $MONGODB_BASE_DIR/templates |
MONGODB_MONGOD_TEMPLATES_FILE | Path to the mongodb.conf template file | $MONGODB_TEMPLATES_DIR/mongodb.conf.tpl |
MONGODB_CONF_FILE | Path to MongoDB configuration file | $MONGODB_CONF_DIR/mongodb.conf |
MONGODB_KEY_FILE | Path to the MongoDB replica set keyfile | $MONGODB_CONF_DIR/keyfile |
MONGODB_DB_SHELL_FILE | Path to MongoDB dbshell file | /.dbshell |
MONGODB_RC_FILE | Path to MongoDB rc file | /.mongorc.js |
MONGOSH_DIR | Path to mongosh directory | /.mongodb |
MONGOSH_RC_FILE | Path to mongosh rc file | /.mongoshrc.js |
MONGODB_PID_FILE | Path to the MongoDB PID file | $MONGODB_TMP_DIR/mongodb.pid |
MONGODB_LOG_FILE | Path to the MongoDB log file | $MONGODB_LOG_DIR/mongodb.log |
MONGODB_INITSCRIPTS_DIR | Path to the MongoDB container init scripts directory | /docker-entrypoint-initdb.d |
MONGODB_DAEMON_USER | MongoDB system user | mongo |
MONGODB_DAEMON_GROUP | MongoDB system group | mongo |
MONGODB_DEFAULT_PORT_NUMBER | MongoDB port set at build time | 27017 |
MONGODB_DEFAULT_ENABLE_JOURNAL | Enable MongoDB journal at build time | true |
MONGODB_DEFAULT_DISABLE_SYSTEM_LOG | Disable MongoDB daemon system log set at build time | false |
MONGODB_DEFAULT_ENABLE_DIRECTORY_PER_DB | Use a separate folder for storing each database data set at build time | false |
MONGODB_DEFAULT_ENABLE_IPV6 | Use IPv6 for database connections set at build time | false |
MONGODB_DEFAULT_SYSTEM_LOG_VERBOSITY | MongoDB daemon log level set at build time | 0 |
MONGODB_DEFAULT_REPLICA_SET_NAME | Name of the MongoDB replica set at build time | replicaset |
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 the mongod service command is possible through the following env var:
MONGODB_EXTRA_FLAGS: Flags to be appended to the mongod startup command. No defaultsMONGODB_CLIENT_EXTRA_FLAGS: Flags to be appended to the mongo command which is used to connect to the (local or remote) mongod daemon. No defaultsconsoledocker 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:
yamlservices: mongodb: ... environment: - ALLOW_EMPTY_PASSWORD=yes - MONGODB_EXTRA_FLAGS=--wiredTigerCacheSizeGB=2 ...
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® documentationconsoledocker 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:
yamlservices: mongodb: ... environment: - ALLOW_EMPTY_PASSWORD=yes - MONGODB_SYSTEM_LOG_VERBOSITY=3 ...
In order to enable launching commands using numactl, set the MONGODB_ENABLE_NUMACTL variable to true. For more information on this, check the official [MongoDB documentation][(<[***]>)
Enabling/disabling IPv6 is possible through the following env var:
MONGODB_ENABLE_IPV6: Whether to enable/disable IPv6 on MongoDB®. Default: false. Possible values: [true, false]To enable IPv6 support, you can execute:
consoledocker run --name mongodb -e ALLOW_EMPTY_PASSWORD=yes -e MONGODB_ENABLE_IPV6=yes bitnami/mongodb:latest
or by modifying the docker-compose.yml file present in this repository:
yamlservices: mongodb: ... environment: - ALLOW_EMPTY_PASSWORD=yes - MONGODB_ENABLE_IPV6=yes ...
Enabling/disabling directoryPerDB is possible through the following env var:
MONGODB_ENABLE_DIRECTORY_PER_DB: Whether to enable/disable directoryPerDB on MongoDB®. Default: true. Possible values: [true, false]consoledocker run --name mongodb -e ALLOW_EMPTY_PASSWORD=yes -e MONGODB_ENABLE_DIRECTORY_PER_DB=yes bitnami/mongodb:latest
or by mo
_Note: the README for this container is longer than the DockerHub length limit of 25000, so it has been trimmed. The full README can be found at [***]
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务