Skip to content

Ollama

Testcontainers module for Ollama .

Ollama usage examples

You can start an Ollama container instance from any NodeJS application by using:

const container = await new OllamaContainer("ollama/ollama:0.1.44").start();

Pulling the model

const execResult = await container.exec(["ollama", "pull", "all-minilm"]);

Create a new Image

In order to create a new image that contains the model, you can use the following code:

await container.commitToImage(newImageName);

And use the new image:

const newContainer = await new OllamaContainer(newImageName).start();

Adding this module to your project

npm install @testcontainers/ollama --save-dev