Skip to content

pcleene/mongot-docker

Repository files navigation

MongoDB + Mongot Local Setup

Local MongoDB replica set with Atlas Search capabilities using the mongot community edition.

Full Guide: See GUIDE.md for comprehensive documentation with concept explanations.

Quick Start

# 1. Start Colima (or Docker Desktop)
colima start

# 2. Run setup
./start.sh

# 3. Connect via Compass
mongodb://admin:password@localhost:27017/?directConnection=true&authSource=admin

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    Docker Compose Network                        │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  ┌──────────┐    ┌──────────┐    ┌──────────┐                   │
│  │ mongod1  │    │ mongod2  │    │ mongod3  │   Replica Set     │
│  │ :27017   │    │ :27018   │    │ :27019   │   (rs0)           │
│  └────┬─────┘    └────┬─────┘    └────┬─────┘                   │
│       │               │               │                          │
│       │ gRPC          │ gRPC          │ gRPC                     │
│       ▼               ▼               ▼                          │
│  ┌──────────┐    ┌──────────┐    ┌──────────┐                   │
│  │ mongot1  │    │ mongot2  │    │ mongot3  │   Search Nodes    │
│  │ (leader) │    │(follower)│    │(follower)│                   │
│  │ :27027   │    │ :27028   │    │ :27029   │                   │
│  └────┬─────┘    └──────────┘    └──────────┘                   │
│       │                                                          │
│       │ HTTPS                                                    │
│       ▼                                                          │
│  ┌─────────────────────────────────┐                            │
│  │  MongoDB AI Embeddings API      │                            │
│  │  ai.mongodb.com/v1/embeddings   │                            │
│  │  (Voyage AI backend)            │                            │
│  └─────────────────────────────────┘                            │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

What's Running

Container Port Description
mongod1 27017 MongoDB Primary
mongod2 27018 MongoDB Secondary
mongod3 27019 MongoDB Secondary
mongot1 27027, 8081 Search (leader)
mongot2 27028, 8082 Search (follower)
mongot3 27029, 8083 Search (follower)

Common Commands

# Start
docker compose up -d

# Stop
docker compose down

# Logs
docker compose logs -f mongot1

# Shell
docker exec -it mongod1 mongosh -u admin -p password --authenticationDatabase admin

# Status
docker exec mongod1 mongosh -u admin -p password --authenticationDatabase admin \
  --eval 'rs.status().members.map(m => ({name: m.name, state: m.stateStr}))'

# Health
curl http://localhost:8081/health

# Full reset
docker compose down -v && ./start.sh

Create a Search Index

// In mongosh
use test

db.movies.insertMany([
  { title: "The Matrix", plot: "A computer hacker learns about reality" },
  { title: "Inception", plot: "Dreams within dreams" }
])

db.movies.createSearchIndex("default", { mappings: { dynamic: true } })

// Wait for index to be READY, then search
db.movies.aggregate([
  { $search: { text: { query: "hacker", path: "plot" } } }
])

Voyage AI Models

Model Use Case Cost
voyage-4-lite Fast/cheap $0.02/M tokens
voyage-4 Balanced $0.06/M tokens
voyage-4-large Best quality $0.18/M tokens
voyage-code-3 Code search $0.18/M tokens

Files

File Purpose
docker-compose.yml Container orchestration
Dockerfile.mongot Builds mongot from public download
mongot-config-leader.yml Leader mongot config
mongot-config-follower.yml Follower mongot config
keyfile Replica set authentication
voyage-api-*-key Voyage AI API keys
start.sh One-command setup
GUIDE.md Comprehensive documentation

Troubleshooting

Problem Solution
Containers not starting docker compose logs
"not primary" error Wait ~30s for election
Can't connect from Compass Use directConnection=true
Search index not building Check docker compose logs mongot1
Full reset needed docker compose down -v && ./start.sh

For detailed explanations of architecture, configuration, and step-by-step instructions, see GUIDE.md.

About

Local MongoDB + Mongot (Atlas Search) Docker setup with auto-embedding vector search

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages