Skip to content


Testcontainers module for Ollama .

Ollama's usage examples

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

OllamaContainer ollama = new OllamaContainer("ollama/ollama:0.1.26")

Pulling the model

Testcontainers allows executing commands in the container. So, pulling the model is as simple as:

ollama.execInContainer("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:


And use the new image along with Image name Substitution

OllamaContainer ollama = new OllamaContainer(

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

testImplementation "org.testcontainers:ollama:1.19.8"