Skip to content

Docker Model Runner

This module helps connect to Docker Model Runner provided by Docker Desktop 4.40.0.

DockerModelRunner's usage examples

You can start a Docker Model Runner proxy container instance from any Java application by using:

DockerModelRunnerContainer dmr = new DockerModelRunnerContainer("alpine/socat:1.7.4.3-r0")

Pulling the model

Pulling the model is as simple as:

RestAssured
    .given()
    .body(String.format("{\"from\":\"%s\"}", modelName))
    .post(dmr.getBaseEndpoint() + "/models/create")
    .then()
    .statusCode(200);

Adding this module to your project dependencies

Docker Model Runner support is part of the core Testcontainers library.

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

testImplementation "org.testcontainers:testcontainers:1.21.0"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers</artifactId>
    <version>1.21.0</version>
    <scope>test</scope>
</dependency>