Databases 4 min read

Deploy MangoDB: An Open‑Source MongoDB Alternative with Docker

This guide introduces MangoDB, an open‑source MongoDB‑compatible database built on PostgreSQL, and walks you through a three‑step Docker‑Compose setup, service startup, and connection using mongosh, enabling developers to quickly try a true open‑source MongoDB replacement.

Programmer DD
Programmer DD
Programmer DD
Deploy MangoDB: An Open‑Source MongoDB Alternative with Docker

MongoDB ranks first in the DB‑Engines list for distributed file‑storage databases and stays within the top five overall, behind legacy systems like Oracle and MySQL. However, due to cloud‑computing pressures, its license switched from GNU AGPLv3 to SSPL, which some consider a drawback for open‑source enthusiasts.

Enter MangoDB , a truly open‑source MongoDB alternative. MangoDB uses PostgreSQL as its storage engine and implements the MongoDB wire protocol in Go, translating MongoDB commands into SQL. It aims for near‑full compatibility with MongoDB drivers, though it is still early in development.

MongoDB ranking
MongoDB ranking

Quickly start using MangoDB in three steps:

1. Create a docker-compose.yml file

version: "3"

services:
  postgres:
    image: postgres:14
    container_name: postgres
    ports:
      - 5432:5432
    environment:
      - POSTGRES_USER=user
      - POSTGRES_DB=mangodb
      - POSTGRES_HOST_AUTH_METHOD=trust

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

  mangodb:
    image: ghcr.io/mangodb-io/mangodb:latest
    container_name: mangodb
    restart: on-failure
    ports:
      - 27017:27017
    command: ["--listen-addr=:27017", "--postgresql-url=postgres://user@postgres:5432/mangodb"]

The postgres service runs PostgreSQL 14 to store data, postgres_setup creates a test schema, and mangodb runs the MangoDB server.

2. Start the services

docker-compose up -d

3. Connect with mongosh

If you already have mongosh installed, simply run it and connect to the MangoDB instance. Otherwise, use Docker to run mongosh inside a container:

docker run --rm -it --network=mangodb_default --entrypoint=mongosh mongo:5 mongodb://mangodb/

With these steps, you can explore MangoDB as a drop‑in replacement for MongoDB, experiment with its features, and contribute improvements.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockerdatabaseopen sourcePostgreSQLMongoDBMangoDB
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.