How to Set Up Memgraph and Qdrant with the cgr Daemon Command
The cgr daemon command launches a pre-configured Docker Compose stack that runs Memgraph and Qdrant locally, binding services to 127.0.0.1 by default for secure, one-command deployment.
Code-Graph-RAG (cgr) provides a containerized backend architecture for graph-based code analysis. Instead of manually configuring database connections, developers use the cgr daemon sub-command to orchestrate both the Memgraph graph database and Qdrant vector store through a unified workflow defined in codebase_rag/docker-compose.yaml.
Stack Components Orchestrated by cgr daemon
The daemon manages three distinct services through the project's Docker Compose configuration:
Memgraph
- Role: Primary graph database storing parsed code relationships and AST nodes
- Ports: Bolt protocol on
7687, HTTP API on7444 - Source: Service definition at
codebase_rag/docker-compose.yamllines 7-11, binding to127.0.0.1by default
Memgraph Lab
- Role: Web-based UI for visualizing and querying graph data
- Port:
3000 - Source: Configured at lines 14-18 with localhost-only binding
Qdrant
- Role: Vector database handling semantic search embeddings
- Ports: HTTP on
6333, gRPC on6334 - Source: Defined at lines 20-24, restricted to the loopback interface
This localhost-only default aligns with the security model documented in docs/architecture/security.md (lines 25-30), ensuring databases remain inaccessible from external networks unless explicitly reconfigured.
Prerequisites
Before executing the daemon command, ensure your environment meets these requirements:
- Docker and Docker Compose installed and running
- Python 3.12 or higher
- The
uvpackage manager (recommended for dependency synchronization)
Complete installation instructions are available in docs/getting-started/installation.md (lines 7-15).
Launching the Stack
Start the complete backend infrastructure using a single command:
cgr daemon up
This command performs three critical operations:
- Image resolution: Pulls or builds required images including
memgraph/memgraph-mage,memgraph/lab, andqdrant/qdrant - Health validation: Blocks until Memgraph's Bolt port accepts connections and Qdrant's HTTP endpoint responds
- Network binding: Publishes all ports on
127.0.0.1as specified in the Compose file
Exposing Services to External Hosts
To override the default localhost-only binding, set the CGR_STACK_BIND_HOST environment variable before execution:
export CGR_STACK_BIND_HOST=0.0.0.0
cgr daemon up
This modifies the bind address defined in the first five lines of codebase_rag/docker-compose.yaml, making the databases reachable from remote machines.
Verifying Deployment
Confirm the stack is operational using the built-in diagnostic tool:
cgr doctor
This command validates connectivity to both Memgraph (via Bolt protocol) and Qdrant (via HTTP), reporting the health status of each service as documented in docs/getting-started/installation.md (lines 35-41).
Shutting Down the Infrastructure
When development is complete, stop and remove the containers gracefully:
cgr daemon down
This terminates all three services and removes the associated Docker network created during startup.
Complete Workflow Example
The following sequence demonstrates a typical development session using the daemon-managed stack:
# Initialize the backend services
cgr daemon up
# Verify health status
cgr doctor
# Ingest a codebase into the graph
cgr start --repo-path /path/to/project --update-graph
# Execute graph queries against Memgraph
cgr query "MATCH (c:Class) RETURN c.name LIMIT 10"
# Terminate services
cgr daemon down
Summary
- The
cgr daemon upcommand provisions Memgraph and Qdrant through Docker Compose without manual configuration - Services bind to
127.0.0.1by default as specified incodebase_rag/docker-compose.yamlfor security - Use
CGR_STACK_BIND_HOSTto customize network exposure when remote access is required - The
cgr doctorcommand validates connectivity to both databases before running ingestion tasks cgr daemon downprovides clean shutdown of the entire stack
Frequently Asked Questions
What ports does the cgr daemon stack expose?
The stack exposes five ports across three services: Memgraph uses Bolt on 7687 and HTTP on 7444, Memgraph Lab serves the UI on 3000, and Qdrant provides HTTP on 6333 and gRPC on 6334. All ports bind to localhost by default according to the service definitions in codebase_rag/docker-compose.yaml.
How do I run the stack on a remote server instead of localhost?
Set the CGR_STACK_BIND_HOST environment variable to 0.0.0.0 or a specific interface IP before executing cgr daemon up. This overrides the default 127.0.0.1 binding defined in the Docker Compose configuration, allowing network access from external hosts.
Can I use a custom Docker Compose file with cgr daemon?
Yes. Point the tool to an alternative Compose file by setting the CGR_COMPOSE_FILE environment variable. This enables customization of service configurations, resource limits, or additional sidecar containers while maintaining the cgr daemon up/down workflow.
Why does cgr daemon block until services are healthy?
The command implements health-check validation to ensure Memgraph accepts Bolt connections and Qdrant responds to HTTP requests before returning control to the shell. This prevents race conditions during subsequent operations like cgr start that require immediate database connectivity.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →