Option 2: A local Docker instance
If you have created a cloud instance of Weaviate, you can skip this page and continue with Communicate with Weaviate.
Here, you will create a Weaviate instance using Docker.
Download and run the docker-compose file
Install Docker on your machine. We recommend following the official Docker installation guide.
Create a new directory and navigate to it in your terminal. Then, create a new file called docker-compose.yml
and add the following content:
---
version: '3.4'
services:
weaviate_anon:
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: cr.weaviate.io/semitechnologies/weaviate:1.28.2
ports:
- 8080:8080
- 50051:50051
restart: on-failure:0
environment:
COHERE_APIKEY: $COHERE_APIKEY
VOYAGEAI_APIKEY: $VOYAGEAI_APIKEY
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
DEFAULT_VECTORIZER_MODULE: 'none'
ENABLE_MODULES: 'text2vec-cohere,multi2vec-voyageai,generative-cohere'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
CLUSTER_HOSTNAME: 'node1'
...
Create a Weaviate instance
Run the following command to start Weaviate:
docker compose up -d
Your Weaviate instance details
Once the instance is created, you can access it at http://localhost:8080
.
Connect to your Weaviate instance
To connect to the Weaviate instance, use the connectToLocal()
function.
import weaviate, { WeaviateClient } from "weaviate-client";
let client: WeaviateClient;
client = await weaviate.connectToLocal()
Provide inference API keys
Some Weaviate modules can use inference APIs for vectorizing data or large language model integration. You can provide the API keys for these services to Weaviate at instantiation.
This course uses VoyageAI, so you can provide the VoyageAI API key to Weaviate through headers: {"X-VoyageAI-Api-Key": <YOUR_KEY>}
as shown below:
import weaviate, { WeaviateClient } from "weaviate-client";
let client: WeaviateClient;
client = await weaviate.connectToLocal({
host: '...',
headers: {
'X-VoyageAI-Api-Key': process.env.VOYAGEAI_APIKEY as string, // Replace with your inference API key
}
})
Questions and feedback
If you have any questions or feedback, let us know in the user forum.