How to Set Up the Memgraph and Qdrant Stack with Docker for Code-Graph-RAG

Pull two official images and expose their standard ports—Memgraph on 7687 and Qdrant on 6333—then verify connectivity with the project's built-in health checks.

The vitali87/code-graph-rag repository combines a native graph database with a vector store to enable semantic search over codebases. Setting up the Memgraph and Qdrant stack with Docker requires running two independent containers that the Python application connects to via standard client libraries.

Memgraph Docker Setup

Memgraph serves as the graph database for storing code relationships and executing Cypher queries. The repository documentation provides the exact command used in development.

Run Memgraph with the published Bolt and HTTP ports:

docker run -p 7687:7687 -p 7444:7444 memgraph/memgraph-platform
  • Port 7687: Bolt protocol for memgraph-client connections
  • Port 7444: HTTP management API and optional web interface

This command appears in docs/claude-code-setup.md at line 55, which covers the Claude Code setup workflow for the project.

For a detached container with a name:

docker run -d --name memgraph \
  -p 7687:7687 -p 7444:7444 \
  memgraph/memgraph-platform

Qdrant Docker Setup

Qdrant provides the vector storage layer for semantic search over code embeddings. While the repository does not include a pre-written Docker command, the official Qdrant image aligns with the client implementation in vector_store.py.

Run Qdrant with REST and gRPC endpoints exposed:

docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
  • Port 6333: REST API used by QdrantClient
  • Port 6334: gRPC endpoint for high-performance operations

For a detached container:

docker run -d --name qdrant \
  -p 6333:6333 -p 6334:6334 \
  qdrant/qdrant

The codebase_rag/vector_store.py file conditionally imports QdrantClient at lines 59-61, establishing the connection to http://localhost:6333 when the vector store initializes.

Combined Docker Compose Configuration

A single docker-compose.yml file simplifies managing both services together:

version: "3.8"
services:
  memgraph:
    image: memgraph/memgraph-platform
    ports:
      - "7687:7687"
      - "7444:7444"

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

Start the complete stack:

docker compose up -d

Verifying Service Connectivity

The project includes health-check utilities that block until both services respond. These helpers are implemented in codebase_rag/tools/health_checker.py and tested in codebase_rag/tests/test_stack_manager.py at lines 110-120.

Basic verification script:

from codebase_rag.stack.manager import wait_for_memgraph, wait_for_qdrant

# Block until services are ready

assert wait_for_memgraph(), "Memgraph connection failed"
assert wait_for_qdrant(), "Qdrant connection failed"

print("Memgraph and Qdrant stack is ready")

Manual client connection example:

from memgraph import Memgraph
from qdrant_client import QdrantClient

# Memgraph connection

memgraph = Memgraph()
memgraph.connect(host="localhost", port=7687)

# Qdrant connection

vector_store = QdrantClient(url="http://localhost:6333")

Key Files and Implementation Details

File Relevance
docs/claude-code-setup.md Contains the Memgraph Docker command at line 55
codebase_rag/vector_store.py Lazy QdrantClient import at lines 59-61
codebase_rag/tools/health_checker.py Implements check_memgraph_connection and check_qdrant_connection
codebase_rag/tests/test_stack_manager.py Health check tests at lines 110-120

Alternative Port Configurations

If the default ports are occupied, map to alternative host ports:

Memgraph on custom ports:

docker run -p 17687:7687 -p 17444:7444 memgraph/memgraph-platform

Update the client connection: Memgraph().connect(host="localhost", port=17687)

Qdrant on custom ports:

docker run -p 16333:6333 -p 16334:6334 qdrant/qdrant

Update the client: QdrantClient(url="http://localhost:16333")

Summary

  • Memgraph runs via docker run -p 7687:7687 -p 7444:7444 memgraph/memgraph-platform as documented in the repository
  • Qdrant runs via docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
  • Both services expose standard ports that match the default client configurations in vector_store.py
  • Use docker compose for unified stack management
  • Verify readiness with wait_for_memgraph() and wait_for_qdrant() from the project's health checker module

Frequently Asked Questions

What ports must be exposed for the code-graph-rag application to work?

Expose 7687 for Memgraph's Bolt protocol and 6333 for Qdrant's REST API. Optional ports 7444 (Memgraph HTTP) and 6334 (Qdrant gRPC) provide additional interfaces for debugging and high-performance access.

Can I run Memgraph and Qdrant without Docker?

Yes, both services offer native installation packages. However, the repository's documentation and health check utilities assume Docker-based deployment with localhost port mappings. Native installations require manual configuration of the client connection parameters.

How do I persist data across container restarts?

Add volume mounts to your Docker commands or compose file. For Memgraph: -v mg_data:/var/lib/memgraph. For Qdrant: -v qdrant_storage:/qdrant/storage. Without volumes, all graph and vector data disappears when containers stop.

Why does the application fail to connect immediately after starting containers?

Both services require initialization time. The wait_for_memgraph() and wait_for_qdrant() functions in codebase_rag/stack/manager.py implement retry logic with timeouts. Use these helpers in startup scripts rather than assuming instantaneous availability.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →