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.
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.
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
