How to Run Dragonfly with Docker: A Quick Start Guide
Get Dragonfly running in under 5 minutes with Docker. Includes vector search setup, docker-compose, and performance tuning for AI workloads.
Getting Started with Dragonfly on Docker
Dragonfly is the fastest way to get a high-performance Redis-compatible data store running on your own infrastructure. In this quick start guide, you will have Dragonfly up and running with Docker in under 5 minutes — including vector search for your AI applications.
Prerequisites
Before starting, ensure you have Docker installed on your system. Dragonfly runs as a single lightweight container with minimal overhead.
Step 1: Pull the Image
docker pull dragonflydb/dragonfly:latest
Step 2: Run Dragonfly
Start Dragonfly with default settings. It listens on port 6379 (Redis-compatible):
docker run --name dragonfly -d --network=host dragonflydb/dragonfly:latest
Or, for a more portable setup with explicit port mapping:
docker run --name dragonfly -d -p 6379:6379 dragonflydb/dragonfly:latest
Step 3: Connect and Verify
Use the Redis CLI to connect to your running Dragonfly instance:
docker exec -it dragonfly redis-cli PING
You should see PONG — Dragonfly is live!
Step 4: Enable Vector Search
Dragonfly supports HNSW vector indexes out of the box. Create a vector index and add embeddings:
# Create an HNSW index for 768-dimensional vectors
FT.CREATE idx ON HASH PREFIX 1 doc: SCHEMA embedding VECTOR HNSW 6 DIM 768 TYPE FLOAT32 DISTANCE_METRIC COSINE
# Add a document with an embedding
HSET doc:1 embedding "0.1,0.2,...0.768"
# Search by similarity
FT.SEARCH idx "*=>[KNN 10 @embedding $vec]" PARAMS 2 vec "0.1,0.2,..." DIALECT 2
Docker Compose Setup
For production deployments with persistence and health checks:
version: '3.8'
services:
dragonfly:
image: dragonflydb/dragonfly:latest
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- ./data/dragonfly:/data
healthcheck:
test: ["CMD", "redis-cli", "PING"]
interval: 10s
timeout: 3s
Performance Tuning
Dragonfly automatically uses all available CPU cores and memory. For fine-tuning, pass flags:
docker run --name dragonfly -d \
-p 6379:6379 \
-v $(pwd)/data:/data \
dragonflydb/dragonfly:latest \
--proactor_threads=4 --cache_mode=true
Conclusion
You now have Dragonfly running as a high-performance in-memory data store with vector search capabilities. Whether you are using it as a drop-in Redis replacement, a semantic cache for LLMs, or a vector database for RAG, Dragonfly delivers exceptional performance with minimal setup effort.