Database service
Services/MongoDB

MongoDB service

Self-hosted MongoDB document database service for applications that store and query JSON-like documents inside a stack.

You add this service to a stack, where you choose its version and resources. Each app environment can override them.

On Wodby

How MongoDB runs on Wodby

What Wodby sets up for this database service, which runs the official MongoDB image. Check it before creating databases or users by hand, or writing a connection string into an application.

Database, user and passwords

Wodby manages the database and its user; the application does not create them.

  • One database and one user are created for the environment, both named after the application and the environment.
  • The user is created in the admin database and has the readWrite role on the environment's database only. A client therefore authenticates against admin (authSource=admin), not against the application database. Authenticating against the application database is the usual reason a correct password is refused.
  • Wodby creates the database by creating a collection named __wodby in it. Leave that collection in place.
  • The administrator is root (MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD in the container). Its password and the user's password are generated once per environment (tokens root_password and password).
  • Creating the user is safe to repeat. A user of the same name that accepts the generated password is kept. One with a different password is left unchanged and the creation fails, so a password changed inside MongoDB is never reset.

How a linked service reaches it

  • Host: the name of this app service inside the environment. Port: 27017.
  • A service linked to this one receives the connection details as environment variables defined by its own link. Read those in the application; do not hardcode them and do not use root from the application.
  • A connection URL that Wodby builds for a link already carries authSource=admin. A URL assembled in the application from host, port, user and password has to add it.

Data, backups and imports

  • Data is on the data volume, mounted at /data/db. The service runs a single instance.
  • The backup is a .tar.gz holding a gzipped mongodump archive of the environment's database and a restore script.
  • The database import takes a .tar.gz or .tgz backup made by this service.
  • The manifest declares no configuration settings; the server runs with the image's defaults.

Check the result

In the database container, mongosh --quiet -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" --authenticationDatabase admin --eval 'db.adminCommand({listDatabases: 1})' lists the databases.

Overview

Technical profile of MongoDB

The versions are the ones you can select for MongoDB in a stack or an app environment. The service itself is published in revisions, and a stack references a specific revision.

Service type

Database service

Versions

8.0

Persistent volumes

Data

Stacks

Stacks that include MongoDB

This public stack includes MongoDB. You can create an app from a public stack as it is, or add the service to a stack of your own.

Data

Backups and data import for MongoDB

The MongoDB service defines how its data is backed up and imported. You run a backup or an import from the app environment that the service belongs to.

Manual and scheduled backups

Run a backup when you need one, or set a schedule in a backup preset.

Import from an archive, a URL, or a backup

An import takes an uploaded archive, a public URL, or a completed backup of a compatible service.

Where archives are stored

Wodby writes each archive to Wodby Blob Storage or to a bucket at a storage provider that you connect as an integration.

Configuration

MongoDB service configuration

The MongoDB service declares the following. Where a value can be changed, a stack sets it and each app environment can override it.

Volumes

Data