How to Install Milvus Vector Database on Ubuntu 26.04
02 Apr, 2026
Introduction
Milvus is an open-source vector database built for large-scale similarity search and artificial intelligence applications. Unlike traditional databases that handle structured text data, Milvus stores and queries high-dimensional vectors, which are mathematical representations of unstructured data like images, audio, text, and videos. The database powers recommendation engines, facial recognition systems, drug discovery platforms, and semantic search applications. Milvus achieves millisecond-level query responses on billion-scale vector datasets through optimized indexing algorithms and supports multiple distance metrics including Euclidean distance and cosine similarity.
This guide shows you how to install Milvus on Ubuntu 26.04 using Docker containerization.
Prerequisites
Before you start:
- Deploy an Ubuntu 26.04 server with at least 8GB of RAM and 4 CPU cores.
- SSH to your server using PuTTY for Windows or Open SSH for Linux and Mac OS.
- Create a non-root user with sudo privileges.
Install Docker Engine
Milvus runs inside Docker containers, so you need Docker installed on your Ubuntu system. Docker provides the runtime environment that isolates Milvus from your host system while ensuring consistent behavior across different deployments.
-
Refresh your system's package list to ensure you get the latest available versions.
console$ sudo apt update -
Install prerequisite packages for Docker.
console$ sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release -
Add Docker's official GPG key.
console$ sudo mkdir -p /etc/apt/keyrings $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -
Add the Docker repository to your apt sources.
console$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null -
Update the package index and install Docker Engine.
console$ sudo apt update $ sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -
Add your non-root user to the docker group.
console$ sudo usermod -aG docker $USER -
Log out and log back in for the group changes to take effect.
console$ exit -
Log in again and verify Docker is working
console$ docker --versionOutput:
Docker version 28.0.1, build 1234567
Pull the Milvus Docker Image
Milvus provides official Docker images through the Docker Hub registry. The milvusdb/milvus image contains the complete Milvus server with all dependencies included.
-
Pull the Milvus Docker image from the official registry.
console$ docker pull milvusdb/milvus:latestOutput:
latest: Pulling from milvusdb/milvus a1234567890b: Pull complete b2345678901c: Pull complete c3456789012d: Pull complete Digest: sha256:abc123def456... Status: Downloaded newer image for milvusdb/milvus:latest docker.io/milvusdb/milvus:latest -
Verify the image downloaded successfully.
console$ docker images | grep milvusOutput:
milvusdb/milvus latest abc123def456 2 weeks ago 2.8GB
Create Milvus Data Directories
Persistent storage ensures your vector data and logs survive container restarts. Create dedicated directories on your host system for Milvus to store its data.
-
Create the directory structure for Milvus.
console$ mkdir -p ~/milvus/data $ mkdir -p ~/milvus/logs $ mkdir -p ~/milvus/config $ mkdir -p ~/milvus/cache -
Set appropriate permissions for these directories.
console$ chmod -R 755 ~/milvus
Run Milvus Container
With the image pulled and directories ready, you can now start the Milvus container. The docker run command creates a container from the Milvus image and maps the necessary ports for client connections.
-
Start the Milvus container with persistent storage.
console$ docker run -d \ --name milvus \ --restart unless-stopped \ -p 19530:19530 \ -p 9091:9091 \ -v ~/milvus/data:/var/lib/milvus/data \ -v ~/milvus/logs:/var/lib/milvus/logs \ -v ~/milvus/config:/var/lib/milvus/config \ -v ~/milvus/cache:/var/lib/milvus/cache \ milvusdb/milvus:latestOutput:
a1b2c3d4e5f67890g1h2i3j4k5l6m7n8o9p0q1r2s3t4u5v6
Manage Milvus Container
Docker manages the Milvus container as a running process on your system. You can control the container using standard Docker commands to start, stop, restart, and check its status.
Check Milvus Container Status
$ docker ps | grep milvus
Output:
a1b2c3d4e5f6 milvusdb/milvus:latest "/tini -- /milvus/bi…" 2 minutes ago Up 2 minutes 0.0.0.0:19530->19530/tcp, 0.0.0.0:9091->9091/tcp milvus
View Milvus Container Logs
$ docker logs milvus
Output:
[INFO] [standalone/standalone.go:123] ["Milvus is ready to serve"]
[INFO] [components/grpc.go:45] ["grpc server listening on port 19530"]
[INFO] [components/http.go:52] ["http server listening on port 9091"]
Press Ctrl + C.
Stop Milvus Container
$ docker stop milvus
Start Milvus Container
$ docker start milvus
Restart Milvus Container
$ docker restart milvus
Configure Firewall for Milvus
Milvus uses two ports for client communication and monitoring. Port 19530 handles gRPC client connections for data operations, while port 9091 exposes health checks and Prometheus metrics.
-
Allow Milvus port 19530 for client connections.
console$ sudo ufw allow 19530/tcpOutput:
Rule added Rule added (v6) -
Allow Milvus port 9091 for monitoring.
console$ sudo ufw allow 9091/tcpOutput:
Rule added Rule added (v6) -
Verify the firewall rules.
console$ sudo ufw statusOutput:
Status: active To Action From -- ------ ---- 19530/tcp ALLOW Anywhere 9091/tcp ALLOW Anywhere 19530/tcp (v6) ALLOW Anywhere (v6) 9091/tcp (v6) ALLOW Anywhere (v6)
Install Python Client for Testing
Milvus provides a Python SDK called PyMilvus for interacting with the database. You will use this client to test your installation by connecting to the Milvus server and performing basic vector operations.
-
Install Python3 and pip if not already present.
console$ sudo apt install -y python3 python3-pip -
Install the PyMilvus Python SDK.
console$ pip3 install pymilvusOutput:
Collecting pymilvus Downloading pymilvus-2.4.0-py3-none-any.whl Successfully installed pymilvus-2.4.0
Test Milvus Installation
Create a Python script to connect to your Milvus server and perform basic operations. This test verifies that the server accepts connections, creates collections, inserts vectors, and executes similarity searches.
-
Create a new test script with Nano.
console$ nano test_milvus.py -
Add the following test code to
test_milvus.py.Pythonfrom pymilvus import connections, Collection, CollectionSchema, FieldSchema, DataType, utility # Connect to Milvus server connections.connect("default", host="localhost", port="19530") print("Connected to Milvus server") # Create a collection schema id_field = FieldSchema(name="id", dtype=DataType.INT64, is_primary=True) vector_field = FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=8) schema = CollectionSchema(fields=[id_field, vector_field], description="Test collection") # Create the collection collection_name = "test_collection" if utility.has_collection(collection_name): utility.drop_collection(collection_name) collection = Collection(name=collection_name, schema=schema) print(f"Created collection: {collection_name}") # Insert sample vectors import random vectors = [[random.random() for _ in range(8)] for _ in range(5)] ids = [i for i in range(5)] collection.insert([ids, vectors]) print(f"Inserted {len(ids)} vectors") # Create an index for fast search index_params = {"index_type": "IVF_FLAT", "metric_type": "L2", "params": {"nlist": 128}} collection.create_index(field_name="embedding", index_params=index_params) print("Created index on vectors") # Load collection into memory for search collection.load() # Perform a similarity search search_vectors = [[random.random() for _ in range(8)]] search_params = {"metric_type": "L2", "params": {"nprobe": 10}} results = collection.search(search_vectors, anns_field="embedding", param=search_params, limit=3) print(f"Search results: {results[0]}") print("Milvus test completed successfully!") -
Save and close the file by pressing Ctrl + X + Y.
-
Run the test script.
console$ python3 test_milvus.pyOutput:
Connected to Milvus server Created collection: test_collection Inserted 5 vectors Created index on vectors Search results: [id: 0, distance: 0.0, id: 1, distance: 1.234, id: 2, distance: 1.567] Milvus test completed successfully!
View Container Resource Usage
Monitor the resource consumption of your Milvus container to ensure it has adequate memory and CPU for your workloads.
-
Display Docker container statistics.
console$ docker stats milvus --no-streamOutput:
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS a1b2c3d4e5f6 milvus 12.34% 1.234GB / 7.789GB 15.85% 1.23MB / 2.34MB 45.6MB / 12.3MB 45
Conclusion
In this guide, you have installed Milvus vector database on Ubuntu 26.04 using Docker, created persistent storage directories for data and logs, configured the firewall to expose the required ports, and tested the installation with the PyMilvus Python SDK. You also learned how to manage the Milvus container with Docker commands and verify the service is ready to serve requests. Now that you have Milvus running, consider integrating it with your machine learning pipelines to index and search vector embeddings from models like BERT, ResNet, or CLIP for semantic search, image retrieval, or recommendation system applications.