Skip to content

Commit 6c5ecca

Browse files
authored
Engdocs 2795 (#22961)
<!--Delete sections as needed --> ## Description Adds Compose 2.38 content (includes some of the WAD updates - more incoming) ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review
1 parent 313a0ae commit 6c5ecca

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
datafolder: compose-cli
3+
datafile: docker_compose_volumes
4+
title: docker compose volumes
5+
layout: cli
6+
---
7+
8+
<!--
9+
Sorry, but the contents of this page are automatically generated from
10+
Docker's source code. If you want to suggest a change to the text that appears
11+
here, you'll need to find the string by searching this repo:
12+
https://github.com/docker/compose
13+
-->
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: Models
3+
description: Learn about the models top-level element
4+
keywords: compose, compose specification, models, compose file reference
5+
weight: 120
6+
---
7+
8+
{{< summary-bar feature_name="Compose models" >}}
9+
10+
The top-level `models` section declares AI models that are used by your Compose application. These models are typically pulled as OCI artifacts, run by a model runner, and exposed as an API that your service containers can consume.
11+
12+
Services can only access models when explicitly granted by a [`models` attribute](services.md#models) within the `services` top-level element.
13+
14+
## Examples
15+
16+
### Example 1
17+
18+
```yaml
19+
services:
20+
app:
21+
image: app
22+
models:
23+
- ai_model
24+
25+
26+
models:
27+
ai_model:
28+
model: ai/model
29+
```
30+
31+
In this basic example:
32+
33+
- The app service uses the `ai_model`.
34+
- The `ai_model` is defined as an OCI artifact (`ai/model`) that is pulled and served by the model runner.
35+
- Docker Compose injects connection info, for example `AI_MODEL_URL`, into the container.
36+
37+
### Example 2
38+
39+
```yaml
40+
services:
41+
app:
42+
image: app
43+
models:
44+
my_model:
45+
endpoint_var: MODEL_URL
46+
47+
models:
48+
my_model:
49+
model: ai/model
50+
context_size: 1024
51+
runtime_flags:
52+
- "--a-flag"
53+
- "--another-flag=42"
54+
```
55+
56+
In this advanced setup:
57+
58+
- The service app references `my_model` using the long syntax.
59+
- Compose injects the model runner's URL as the environment variable `MODEL_URL`.
60+
61+
## Attributes
62+
63+
- `model` (required): The OCI artifact identifier for the model. This is what Compose pulls and runs via the model runner.
64+
- `context_size`: Defines the maximum token context size for the model.
65+
- `runtime_flags`: A list of raw command-line flags passed to the inference engine when the model is started.

content/reference/compose-file/services.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,41 @@ There is a performance penalty for applications that swap memory to disk often.
12881288
- If `memswap_limit` is unset, and `memory` is set, the container can use as much swap as the `memory` setting, if the host container has swap memory configured. For instance, if `memory`="300m" and `memswap_limit` is not set, the container can use 600m in total of memory and swap.
12891289
- If `memswap_limit` is explicitly set to -1, the container is allowed to use unlimited swap, up to the amount available on the host system.
12901290

1291+
### models
1292+
1293+
{{< summary-bar feature_name="Compose models" >}}
1294+
1295+
`models` defines which AI models the service should use at runtime. Each referenced model must be defined under the [`models` top-level element](models.md).
1296+
1297+
```yaml
1298+
services:
1299+
short_syntax:
1300+
image: app
1301+
models:
1302+
- my_model
1303+
long_syntax:
1304+
image: app
1305+
models:
1306+
my_model:
1307+
endpoint_var: MODEL_URL
1308+
model_var: MODEL
1309+
```
1310+
1311+
When a service is linked to a model, Docker Compose injects environment variables to pass connection details and model identifiers to the container. This allows the application to locate and communicate with the model dynamically at runtime, without hard-coding values.
1312+
1313+
#### Long syntax
1314+
1315+
The long syntax gives you more control over the environment variable names.
1316+
1317+
- `endpoint_var` sets the name of the environment variable that holds the model runner’s URL.
1318+
- `model_var` sets the name of the environment variable that holds the model identifier.
1319+
1320+
If either is omitted, Compose automatically generates the environment variable names based on the model key using the following rules:
1321+
1322+
- Convert the model key to uppercase
1323+
- Replace any '-' characters with '_'
1324+
- Append `_URL` for the endpoint variable
1325+
12911326
### `network_mode`
12921327

12931328
`network_mode` sets a service container's network mode.

data/summary.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Compose mac address:
107107
requires: Docker Compose [2.23.2](/manuals/compose/releases/release-notes.md#2232) and later
108108
Compose menu:
109109
requires: Docker Compose [2.26.0](/manuals/compose/releases/release-notes.md#2260) and later
110+
Compose models:
111+
requires: Docker Compose [2.38.0](/manuals/compose/releases/release-notes.md#2380) and later
110112
Compose model runner:
111113
requires: Docker Compose [2.35.0](/manuals/compose/releases/release-notes.md#2350) and later, and Docker Desktop 4.41 and later
112114
Compose OCI artifact:

0 commit comments

Comments
 (0)