---
title: "Build a GenAI App With Java Using Spring AI and Docker Model Runner"
description: "A Spring Boot GenAI app can run entirely on local models by pointing Spring AI's OpenAI module at Docker Model Runner's OpenAI-compatible endpoint, using llama3.1 for chat and mxbai-embed-large for embeddings."
url: "https://swe.quest/articles/build-a-genai-app-with-java-using-spring-ai-and-docker-model-runner-2e0c221c42a705e5"
canonical: "https://www.docker.com/blog/build-genai-app-with-java-spring-ai-docker-model-runner/"
source: "Docker"
published: "2025-07-11"
difficulty: "medium"
kind: "How-to"
reading_minutes: 11
tags: ["rag","jvm","testing","llms","observability"]
---

# Build a GenAI App With Java Using Spring AI and Docker Model Runner

A post on [Docker](https://swe.quest/sources/docker.md), published 2025-07-11, 11 min read, How-to. Original: [https://www.docker.com/blog/build-genai-app-with-java-spring-ai-docker-model-runner/](https://www.docker.com/blog/build-genai-app-with-java-spring-ai-docker-model-runner/)

## Summary

A Spring Boot GenAI app can run entirely on local models by pointing Spring AI's OpenAI module at Docker Model Runner's OpenAI-compatible endpoint, using llama3.1 for chat and mxbai-embed-large for embeddings. A plain /chat endpoint hallucinates details about Testcontainers, such as nonexistent classes and URLs. A /rag endpoint uses QuestionAnswerAdvisor over a Qdrant vector store, with documents ingested via TokenTextSplitter, and grounds the answer in the supplied docs. An integration test built on Testcontainers and Spring AI's FactCheckingEvaluator automatically checks that answers are supported by the retrieved documents, and the Grafana LGTM stack is then wired in for observability.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)

## Prerequisites

- Spring Boot
- RAG basics ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- Docker ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))

## Keywords

Spring AI, Docker Model Runner, Qdrant, Testcontainers, Llama 3.1, FactCheckingEvaluator, Grafana LGTM

## Related posts

- [How to Make an AI Chatbot from Scratch using Docker Model Runner](https://swe.quest/articles/how-to-make-an-ai-chatbot-from-scratch-using-docker-model-runner-48eab58e2814218f.md): Docker · 2025-06-03 · Medium · 17 min read · Inference & serving, Observability, LLMs, Go, Containers
  A local GenAI chatbot built on Docker Model Runner, which runs llama.cpp models natively on the host and exposes an OpenAI-compatible API to containers.
- [Run Gemma 3 with Docker Model Runner: Fully Local GenAI Developer Experience](https://swe.quest/articles/run-gemma-3-with-docker-model-runner-fully-local-genai-developer-experience-c005339b3915484f.md): Docker · 2025-04-09 · Medium · 7 min read · LLMs, Inference & serving, Containers, JavaScript
  Docker Model Runner (in Docker Desktop for macOS 4.40.0+) exposes an OpenAI-compatible API on localhost, so Gemma 3 can be pulled with \`docker model pull ai/gemma3\` and called through the standard OpenAI SDK by pointing baseURL at http://localhost:12434/engines/v1.
- [How to Build, Run, and Package AI Models Locally with Docker Model Runner](https://swe.quest/articles/how-to-build-run-and-package-ai-models-locally-with-docker-model-runner-acbc6d65548e5373.md): Docker · 2025-06-12 · Medium · 6 min read · Inference & serving, LLMs, Containers, Developer tools
  Docker Model Runner, enabled as a beta feature in Docker Desktop 4.40+, pulls GGUF-format LLMs from Docker Hub or Hugging Face and runs them locally via the \`docker model\` CLI or an OpenAI-compatible HTTP endpoint on localhost.
- [Building an Easy Private AI Assistant with Goose and Docker Model Runner](https://swe.quest/articles/building-an-easy-private-ai-assistant-with-goose-and-docker-model-runner-6cdc8d1a08ce794b.md): Docker · 2025-06-27 · Medium · 4 min read · AI agents, LLMs, Inference & serving, Developer tools
  Goose, a CLI AI assistant, can run entirely on a local model by pointing its OpenAI provider at Docker Model Runner's OpenAI-compatible endpoint.
- [AI-Powered Testing: Using Docker Model Runner with Microcks for Dynamic Mock APIs](https://swe.quest/articles/ai-powered-testing-using-docker-model-runner-with-microcks-for-dynamic-mock-apis-5407790a30e64f9c.md): Docker · 2025-07-14 · Medium · 4 min read · Testing, LLMs, Containers, Developer tools
  Microcks' AI Copilot can generate varied, realistic mock API responses using a local LLM served by Docker Model Runner through its OpenAI-compatible endpoint.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
