Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Environment:PacktPublishing LLM Engineers Handbook Docker MongoDB Qdrant Infrastructure

From Leeroopedia
Revision as of 18:27, 16 February 2026 by Admin (talk | contribs) (Auto-imported from environments/PacktPublishing_LLM_Engineers_Handbook_Docker_MongoDB_Qdrant_Infrastructure.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Infrastructure, Databases
Last Updated 2026-02-08 08:00 GMT

Overview

Docker Compose environment running MongoDB (document store) and Qdrant (vector database) as local infrastructure services.

Description

This environment provides the two database backends required by the LLM Twin application. MongoDB serves as the NoSQL data warehouse for raw crawled documents (articles, posts, repositories) and user profiles. Qdrant serves as the vector database for cleaned documents, chunks, and embedded chunks used in the RAG pipeline. Both services run as Docker containers via `docker-compose.yml` with default credentials and port mappings.

Usage

Use this environment for all local development and testing. MongoDB is required for the Digital Data ETL and Feature Engineering workflows. Qdrant is required for Feature Engineering, Dataset Generation, and RAG Inference workflows. For cloud deployments, Qdrant Cloud can be used instead of the local container by setting `USE_QDRANT_CLOUD=True`.

System Requirements

Category Requirement Notes
Docker >= 27.1.1 Docker Compose v2 included
Disk ~2GB free For MongoDB and Qdrant data volumes
Network Ports 27017, 6333, 6334 available MongoDB and Qdrant default ports

Dependencies

Docker Images

  • `mongo:latest` (MongoDB)
  • `qdrant/qdrant:latest` (Qdrant vector database)

Python Packages (clients)

  • `pymongo` >= 4.6.2 (MongoDB driver)
  • `qdrant-client` >= 1.8.0 (Qdrant client)

Credentials

The following environment variables configure database access:

  • `DATABASE_HOST`: MongoDB connection string (default: `mongodb://llm_engineering:llm_engineering@127.0.0.1:27017`)
  • `DATABASE_NAME`: MongoDB database name (default: `twin`)
  • `QDRANT_DATABASE_HOST`: Qdrant host (default: `localhost`)
  • `QDRANT_DATABASE_PORT`: Qdrant port (default: `6333`)
  • `USE_QDRANT_CLOUD`: Boolean flag for Qdrant Cloud (default: `False`)
  • `QDRANT_CLOUD_URL`: Qdrant Cloud URL (required if `USE_QDRANT_CLOUD=True`)
  • `QDRANT_APIKEY`: Qdrant Cloud API key (required if `USE_QDRANT_CLOUD=True`)

Quick Install

# Start local infrastructure
docker compose up -d

# Verify services are running
docker compose ps

Code Evidence

MongoDB container configuration from `docker-compose.yml:2-17`:

mongo:
  image: mongo:latest
  environment:
    MONGO_INITDB_ROOT_USERNAME: "llm_engineering"
    MONGO_INITDB_ROOT_PASSWORD: "llm_engineering"
  ports:
    - 27017:27017

Qdrant container configuration from `docker-compose.yml:19-32`:

qdrant:
  image: qdrant/qdrant:latest
  ports:
    - 6333:6333
    - 6334:6334

MongoDB singleton connection from `llm_engineering/infrastructure/db/mongo.py:14`:

cls._instance = MongoClient(settings.DATABASE_HOST)

Qdrant connection with cloud fallback from `llm_engineering/infrastructure/db/qdrant.py:14-27`:

if settings.USE_QDRANT_CLOUD:
    cls._instance = QdrantClient(
        url=settings.QDRANT_CLOUD_URL,
        api_key=settings.QDRANT_APIKEY,
    )
else:
    cls._instance = QdrantClient(
        host=settings.QDRANT_DATABASE_HOST,
        port=settings.QDRANT_DATABASE_PORT,
    )

Common Errors

Error Message Cause Solution
`Connection refused` on port 27017 MongoDB container not running Run `docker compose up -d`
`Connection refused` on port 6333 Qdrant container not running Run `docker compose up -d`
`Authentication failed` for MongoDB Wrong credentials Verify `DATABASE_HOST` matches docker-compose credentials

Compatibility Notes

  • Qdrant Cloud: Set `USE_QDRANT_CLOUD=True` with `QDRANT_CLOUD_URL` and `QDRANT_APIKEY` to use managed Qdrant instead of local container.
  • Docker Desktop: On macOS/Windows, Docker Desktop must be running before `docker compose up`.
  • Port Conflicts: If ports 27017 or 6333 are already in use, modify `docker-compose.yml` and update the corresponding settings.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment