Skip to content

guides: add agentic guide #22937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 281 additions & 0 deletions content/guides/agentic-ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
---
title: Build and run agentic AI applications with Docker

Check failure on line 2 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'agentic'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'agentic'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 2, "column": 22}}}, "severity": "ERROR"}
linktitle: Agentic AI applications

Check failure on line 3 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'Agentic'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'Agentic'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 3, "column": 12}}}, "severity": "ERROR"}
keywords: AI, Docker, Model Runner, MCP Toolkit, Docker Offload, AI agents, application development
summary: |
Learn how to create AI agent applications using Docker Model Runner, MCP Toolkit, and Docker Offload.
params:
tags: [AI]
time: 30 minutes
---

## Introduction

Agentic applications are transforming how software gets built. These apps don't

Check failure on line 14 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'Agentic'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'Agentic'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 14, "column": 1}}}, "severity": "ERROR"}
just respond, they decide, plan, and act. They're powered by models,
orchestrated by agents, and integrated with APIs, tools, and services in real
time.

All these new agentic applications, no matter what they do, share a common

Check failure on line 19 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'agentic'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'agentic'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 19, "column": 15}}}, "severity": "ERROR"}
architecture. It's a new kind of stack, built from three core components:

- Models: These are your GPTs, CodeLlamas, Mistrals. They're doing the
reasoning, writing, and planning. They're the engine behind the intelligence.

- Agent: This is where the logic lives. Agents take a goal, break it down, and
figure out how to get it done. They orchestrate everything. They talk to the
UI, the tools, the model, and the gateway.

- MCP gateway: This is what links your agents to the outside world, including
APIs, tools, and services. It provides a standard way for agents to call
capabilities via the Model Context Protocol (MCP).

Docker makes this AI-powered stack simpler, faster, and more secure by unifying
models, tool gateways, and cloud infrastructure into a developer-friendly
workflow that uses Docker Compose.

![A diagram of the agentic stack](./images/agentic-ai-diagram.webp)

Check failure on line 37 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'agentic'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'agentic'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 37, "column": 20}}}, "severity": "ERROR"}

This guide walks you through the core components of agentic development and

Check failure on line 39 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'agentic'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'agentic'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 39, "column": 53}}}, "severity": "ERROR"}
shows how Docker ties them all together with the following tools:

- [Docker Model Runner](../manuals/ai/model-runner/_index.md) lets you run LLMs
locally with simple command and OpenAI-compatible APIs.
- [Docker MCP Catalog and
Toolkit](../manuals/ai/mcp-catalog-and-toolkit/_index.md) helps you discover
and securely run external tools, like APIs and databases, using the Model
Context Protocol (MCP).
- [Docker MCP Gateway](/ai/mcp-gateway/) lets you orchestrate and manage MCP servers.
- [Docker Offload](/offload/) provides a powerful, GPU-accelerated
environment to run your AI applications with the same Compose-based
workflow you use locally.
- [Docker Compose](../manuals/compose/_index.md) is the tool that ties it all
together, letting you define and run multi-container applications with a
single file.

For this guide, you'll start by running the app in Docker Offload, using the same
Compose workflow you're already familiar with. Then, if your machine hardware
supports it, you'll run the same app locally using the same workflow. Finally,
you'll dig into the Compose file and app to see how it all works together.

## Prerequisites

To follow this guide, you need to:

- [Install Docker Desktop 4.43 or later](../get-started/get-docker.md)
- [Enable Docker Model Runner](/ai/model-runner/#enable-dmr-in-docker-desktop)
- [Join Docker Offload Beta](/offload/quickstart/)

## Step 1: Clone the sample application

You'll use an existing sample application that demonstrates how to connect a
model to an external tool using Docker's AI features.

```console
$ git clone https://github.com/docker/TBD.git
$ cd TBD/adk/
```

## Step 2: Run the application with Docker Offload

You'll start by running the application in Docker Offload, which provides a
managed environment for running AI workloads. This is ideal if you want to
leverage cloud resources or if your local machine doesn't meet the hardware
requirements to run the model locally. Docker Offload includes support for
GPU-accelerated instances, making it ideal for compute-intensive workloads like
AI model inference.

To run the application with Docker Offload, follow these steps:

1. Sign in to the Docker Desktop Dashboard.
2. In a terminal, start Docker Offload by running the following command:

```console
$ docker offload start
```

When prompted, choose the account you want to use for Docker Offload and select
**Yes** when prompted **Do you need GPU support?**.

3. In the `adk/` directory of the cloned repository, run the following command
in a terminal to build and run the application:

```console
$ docker compose up
```

The model is large. The first time you run this command, Docker pulls the
model from Docker Hub, which may take some time.

The application is now running with Docker Offload. Note that the Compose workflow
is the same when using Docker Offload as it is locally. You define your
application in a `compose.yaml` file, and then use `docker compose up` to build
and run it.

4. Visit [http://localhost:8080](http://localhost:8080). Enter something in the
prompt and hit enter. An agent searches DuckDuckGo and another agent revises
the output.

![Screenshot of the application](./images/agentic-ai-app.png)

5. Press ctrl-c in the terminal to stop the application when you're done.

6. Run the following command to stop Docker Offload:

```console
$ docker offload stop
```

## Step 3: Optional. Run the application locally

If your machine meets the necessary hardware requirements, you can run the
entire application stack locally using Docker Compose. This lets you test the
application end-to-end, including the model and MCP gateway, without needing to
run in the cloud. This particular example uses the 27B parameter Gemma 3 model,
which is designed to run on high-end hardware.

Hardware requirements:
- VRAM: 18.78GiB

Check warning on line 138 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Docker.Acronyms] 'VRAM' has no definition. Raw Output: {"message": "[Docker.Acronyms] 'VRAM' has no definition.", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 138, "column": 4}}}, "severity": "WARNING"}
- Storage: 16.04GB

If your machine does not meet these requirements, you may still be able to run
the application, but you will need update your `compose.yaml` file to use a
smaller model which won't perform as well, such as `ai/gemma3-qat:4B-Q4_K_M`.

To run the application locally, follow these steps:

1. In the `adk/` directory of the cloned repository, run the following command in a
terminal to build and run the application:

```console
$ docker compose up
```

The model is large. The first time you run this command, Docker pulls the
model from Docker Hub, which may take some time.

2. Visit [http://localhost:8080](http://localhost:8080). Enter something in the
prompt and hit enter. An agent searches DuckDuckGo and another agent revises the
output.

3. Press ctrl-c in the terminal to stop the application when you're done.

## Step 4: Review the application environment

The app is defined using Docker Compose, with three services:

- An `adk` web app service that talks to the MCP gateway and the local model
- A `docker-model-runner` service that runs the model
- An `mcp-gateway` service that manages tool execution via MCP

You can find the `compose.yaml` file in the `adk/` directory. Open it in a text
editor to see how the services are defined.

```yaml
TBD
```

The first notable element here is the `provider` section that specifies `type:
model`, which lets Docker Compose know to use the Docker Model Runner component.
The `options` section defines the specific model to run, in this case,
[`ai/gemma3-qat:27B-Q4_K_M`](https://hub.docker.com/r/ai/gemma3-qat).

> [!TIP]
>
> Looking for more models to use? Check out the [Docker AI Model
> Catalog](https://hub.docker.com/catalogs/models/).

The second notable element is `image: docker/agents_gateway:v2`, which indicates
that the MCP gateway service will use the [docker/agents_gateway:v2
image](https://hub.docker.com/r/docker/agents_gateway). This image is Docker's
open source [MCP Gateway](https://github.com/docker/docker-mcp/) that enables
your application to connect to MCP servers, which expose tools that models can
call. In this example, it uses the [`duckduckgo` MCP
server](https://hub.docker.com/mcp/server/duckduckgo/overview) to perform web
searches.

> [!TIP]
>
> Looking for more MCP servers to use? Check out the [Docker MCP
> Catalog](https://hub.docker.com/catalogs/mcp/).

Those two components, the Docker Model Runner and the MCP gateway, are the
core of the agentic stack. They let you run models locally and connect them to

Check failure on line 203 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'agentic'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'agentic'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 203, "column": 13}}}, "severity": "ERROR"}
external tools and services using the Model Context Protocol.

## Step 5: Review the application

The `adk` web application is an agent implementation that connects to the MCP
gateway and a local model through environment variables and API calls. It uses
the [ADK (Agent Development Kit)](https://github.com/google/adk-python) to

Check warning on line 210 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Docker.Acronyms] 'ADK' has no definition. Raw Output: {"message": "[Docker.Acronyms] 'ADK' has no definition.", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 210, "column": 6}}}, "severity": "WARNING"}
define a root agent named Auditor, which coordinates two sub-agents, Critic and
Reviser, to verify and refine model-generated answers.

The three agents are:

- Critic: Verifies factual claims using the toolset, such as DuckDuckGo.

Check failure on line 216 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'toolset'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'toolset'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 216, "column": 45}}}, "severity": "ERROR"}
- Reviser: Edits answers based on the verification verdicts provided by the Critic.
- Auditor: A higher-level agent that sequences the
Critic and Reviser. It acts as the entry point, evaluating LLM-generated
answers, verifying them, and refining the final output.

All of the application's behavior is defined in Python under the `agents/`
directory. Here's a breakdown of the notable files:

- `agents/agent.py`: Defines the Auditor, a SequentialAgent that chains together
the Critic and Reviser agents. This agent is the main entry point of the
application and is responsible for auditing LLM-generated content using
real-world verification tools.

- `agents/sub_agents/critic/agent.py`: Defines the Critic agent. It loads the
language model (via Docker Model Runner), sets the agent’s name and behavior,
and connects to MCP tools (like DuckDuckGo).

- `agents/sub_agents/critic/prompt.py`: Contains the Critic prompt, which
instructs the agent to extract and verify claims using external tools.

- `agents/sub_agents/critic/tools.py`: Defines the MCP toolset configuration,

Check failure on line 237 in content/guides/agentic-ai.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'toolset'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'toolset'?", "location": {"path": "content/guides/agentic-ai.md", "range": {"start": {"line": 237, "column": 56}}}, "severity": "ERROR"}
including parsing `mcp/` strings, creating tool connections, and handling MCP
gateway communication.

- `agents/sub_agents/reviser/agent.py`: Defines the Reviser agent, which takes
the Critic’s findings and minimally rewrites the original answer. It also
includes callbacks to clean up the LLM output and ensure it's in the right
format.

- `agents/sub_agents/reviser/prompt.py`: Contains the Reviser prompt, which
instructs the agent to revise the answer text based on the verified claim
verdicts.

The MCP gateway is configured via the `MCPGATEWAY_ENDPOINT` environment
variable. In this case, `http://mcp-gateway:8811/sse`. This allows the app to
use Server-Sent Events (SSE) to communicate with the MCP gateway container,
which itself brokers access to external tool services like DuckDuckGo.

## Summary

Agent-based AI applications are emerging as a powerful new software
architecture. In this guide, you explored a modular, chain-of-thought system
where an Auditor agent coordinates the work of a Critic and a Reviser to
fact-check and refine model-generated answers. This architecture shows how to
combine local model inference with external tool integrations in a structured,
modular way.

You also saw how Docker simplifies this process by providing a suite of tools
that support local and cloud-based agentic AI development:

- [Docker Model Runner](../manuals/ai/model-runner/_index.md): Run and serve
open-source models locally via OpenAI-compatible APIs.
- [Docker MCP Catalog and
Toolkit](../manuals/ai/mcp-catalog-and-toolkit/_index.md): Launch and manage
tool integrations that follow the Model Context Protocol (MCP) standard.
- [Docker MCP Gateway](/ai/mcp-gateway/): Orchestrate and manage
MCP servers to connect agents to external tools and services.
- [Docker Compose](../manuals/compose/_index.md): Define and run multi-container
applications with a single file, using the same workflow locally and in the
cloud.
- [Docker Offload](/offload/): Run GPU-intensive AI workloads in a secure, managed
cloud environment using the same Docker Compose workflow you use locally.

With these tools, you can develop and test agentic AI applications efficiently,
locally or in the cloud, using the same consistent workflow throughout.
Binary file added content/guides/images/agentic-ai-app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/guides/images/agentic-ai-diagram.webp
Binary file not shown.
Loading