Self-host MongoDB with Levelrail
The MongoDB document database on the official image, with a persistent volume and a generated root user and password. It is not published on the host, so reach it from other services in this project at mongodb:27017.
- Authormongodb
- LicenceLicenseRef-SSPL-1.0
- Memory512 MiB
- Services1
How to self-host MongoDB
-
Pull the images
One image is pulled on your server.
Show images
mongo:8.0.34
-
Create the app
One service starts in a single Compose app, with 2 named volume mounts for your data, on port 27017.
-
Fill in the secrets
2 secrets are generated and stored encrypted, you do not have to fill in anything.
-
Open it
Without a domain the app gets an sslip.io address; add --domain SERVICE=HOST to use your own.
After the first start
- Read the generated root user and password from the app secrets, then connect from a service in the same project with mongodb://USER:PASSWORD@mongodb:27017/?authSource=admin.
MongoDB requirements
- Memory
- About 512 MiB
- Architectures
- amd64 unknown, arm64 unknown
- Ports
- 27017
- Domain
- Optional, an sslip.io address is used without one
- Settings
- none to fill in
- License
- LicenseRef-SSPL-1.0, source available
- Listed. It is in the catalog but not verified. Back up the data volume before changing an image tag.
Install Levelrail first
On a server with Levelrail running, run the command above, or open the dashboard: Apps, New app, Browse templates, then MongoDB. New to Levelrail? Install it on a fresh VPS first.
docker pull ghcr.io/glincker/levelrail:latest Then levelrail-cli login --device. See Getting started and the MongoDB docs page.
Deploy MongoDB your way
Every format below deploys the same pinned images. Pick the one that fits how you work.
Deploy MongoDB from the CLI
levelrail-cli templates deploy mongodb --name my-mongodb Deploy MongoDB with the API
curl -X POST -H "Authorization: Bearer $TOKEN" \
https://levelrail.example.com/api/v1/service-templates/mongodb/deploy MongoDB configuration
MongoDB services
| Service | Image | Ports | Volumes |
|---|---|---|---|
| mongodb | mongo:8.0.34 | 27017 | mongodb_data -> /data/dbmongodb_config -> /data/configdb |
MongoDB environment variables
| Variable | Service | Value |
|---|---|---|
| MONGO_INITDB_ROOT_PASSWORD | mongodb | Generated at deploy |
| MONGO_INITDB_ROOT_USERNAME | mongodb | Generated at deploy |
Ports and volumes
- Ports
- 27017
- Volumes
- 2 named mounts: mongodb_data -> /data/db, mongodb_config -> /data/configdb
MongoDB FAQ
How much memory does MongoDB need?
The catalog lists about 512 MiB of memory for MongoDB.
Does MongoDB run on arm64?
For MongoDB, arm64 support is not confirmed; amd64 is unknown.
What licence is MongoDB under?
MongoDB is licensed under LicenseRef-SSPL-1.0, which is source-available, so read the terms before commercial use.
Does MongoDB need configuration before it starts?
No. The template fills in its own defaults and generates secrets at deploy time.
Which database does MongoDB bundle?
The template includes MongoDB, running as part of the stack.
Which ports does MongoDB use?
MongoDB listens on port 27017 inside the stack.
Where does MongoDB keep its data?
In named volumes: mongodb_data mounted at /data/db and mongodb_config mounted at /data/configdb.
Can I deploy MongoDB on Dokploy or Dokku?
The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for MongoDB, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image mongo:8.0.34 is what you deploy there.