A Golang-based MongoDB alternative

FerretDB (previously MangoDB) was founded to become the de-facto open-source substitute to MongoDB. FerretDB is an open-source proxy, converting the MongoDB 5.0+ wire protocol queries to SQL – using PostgreSQL as a database engine.

Why do we need a MongoDB alternative in Golang?

MongoDB was originally an eye-opening technology for many developers, empowering us to build applications faster than relational databases. In its early days, its ease-to-use and well-documented drivers made MongoDB one of the simplest database solutions. However, as time passed, MongoDB abandoned its open-source roots, changing the license to SSPL – making it unusable for many open source and early-stage commercial projects.

Most MongoDB users do not require any advanced features offered by MongoDB; however, they need an easy-to-use open-source database solution. Recognizing this, FerretDB is here to fill that gap.

Scope and current state

FerretDB will be compatible with MongoDB drivers and will strive to serve as a drop-in replacement for MongoDB 5.0+.

Currently, the project is in its early stages and welcomes all contributors.

Known differences to MongoDB

  1. FerretDB uses the same protocol error names and codes, but the exact error messages may be different in some cases.
  2. FerretDB does not support NUL (\0) characters in strings.
  3. Database and collection names restrictions:
  • name cannot start with the reserved prefix _ferretdb_.
  • name must not include non-Latin letters, spaces, dots, dollars, or dashes.
  • collection name length must be less or equal to 120 symbols, database name length limit is 63 symbols.
  • name must not start with a number.
  • the database name cannot contain capital letters.

If you encounter some other difference in behavior, please join our community to report a problem.

Quickstart with Docker Compose and Golang

These steps describe a quick local setup. They are unsuitable for most production use-cases because they keep all data inside containers.

  1. Store the following in the docker-compose.yml file:
version: "3"

    image: postgres:14
    container_name: postgres
      - 5432:5432
      - POSTGRES_USER=user
      - POSTGRES_DB=ferretdb

    image: postgres:14
    container_name: postgres_setup
    restart: on-failure
    entrypoint: ["sh", "-c", "psql -h postgres -U user -d ferretdb -c 'CREATE SCHEMA IF NOT EXISTS test'"]

    image: ghcr.io/ferretdb/ferretdb:latest
    container_name: ferretdb
    restart: on-failure
      - 27017:27017
    command: ["-listen-addr=:27017", "-postgresql-url=postgres://[email protected]:5432/ferretdb"]

    name: ferretdb
  • postgres container runs PostgreSQL 14 that would store data.
  • postgres_setup container creates a PostgreSQL schema test that would act like a FerretDB database of the same name.
  • ferretdb runs FerretDB.
  1. Start services with docker-compose up -d.
  2. If you have mongosh installed, just run it to connect to FerretDB database test. If not, run the following command to run mongosh inside the temporary MongoDB container, attaching to the same Docker network:
docker run --rm -it --network=ferretdb --entrypoint=mongosh mongo:5 mongodb://ferretdb/

You can also install with FerretDB with the .deb and .rpm packages provided for each release.