Skip to content

Commit 47560c5

Browse files
authored
Merge pull request #21980 from docker/published-update
publish updates from main
2 parents c50bc4f + 4e1eb29 commit 47560c5

File tree

5 files changed

+54
-7
lines changed

5 files changed

+54
-7
lines changed

content/manuals/compose/how-tos/depent-images.md renamed to content/manuals/compose/how-tos/dependent-images.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Build dependent images
55
weight: 50
66
---
77

8+
{{< summary-bar feature_name="Compose dependent images" >}}
9+
810
To reduce push/pull time and image weight, a common practice for Compose applications is to have services
911
share base layers as much as possible. You will typically select the same operating system base image for
1012
all services. But you also can get one step further sharing image layers when your images share the same
@@ -19,7 +21,6 @@ image and install system package `openssl`.
1921
The recommended approach is to group the shared declaration in a single Dockerfile, and use multi-stage features
2022
so that service images are built from this shared declaration.
2123

22-
2324
Dockerfile:
2425

2526
```dockerfile
@@ -53,7 +54,6 @@ A popular pattern is to reuse a service image as a base image in another service
5354
As Compose does not parse the Dockerfile, it can't automatically detect this dependency
5455
between services to correctly order the build execution.
5556
56-
5757
a.Dockerfile:
5858
5959
```dockerfile
@@ -82,7 +82,6 @@ services:
8282
dockerfile: b.Dockerfile
8383
```
8484
85-
8685
Legacy Docker Compose v1 used to build images sequentially, which made this pattern usable
8786
out of the box. Compose v2 uses BuildKit to optimise builds and build images in parallel
8887
and requires an explicit declaration.
@@ -107,7 +106,6 @@ services:
107106
service_a: "service:a"
108107
```
109108
110-
111109
## Build with Bake
112110
113111
Using [Bake](/manuals/build/bake/_index.md) let you pass the complete build definition for all services

content/reference/compose-file/build.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,28 @@ the unused contexts.
118118
Illustrative examples of how this is used in Buildx can be found
119119
[here](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-additional-build-contexts---build-context).
120120

121+
`additional_contexts` can also refer to an image built by another service.
122+
This allows a service image to be built using another service image as a base image, and to share
123+
layers between service images.
124+
125+
```yaml
126+
services:
127+
base:
128+
build:
129+
context: .
130+
dockerfile_inline: |
131+
FROM alpine
132+
RUN ...
133+
base:
134+
build:
135+
context: .
136+
dockerfile_inline: |
137+
FROM base # image built for service base
138+
RUN ...
139+
additional_contexts:
140+
base: service:base
141+
```
142+
121143
### `args`
122144

123145
`args` define build arguments, that is Dockerfile `ARG` values.

content/reference/compose-file/merge.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ While these types are modeled in a Compose file as a sequence, they have special
107107
| Attribute | Unique key |
108108
|-------------|--------------------------|
109109
| volumes | target |
110-
| secrets | source |
111-
| configs | source |
110+
| secrets | target |
111+
| configs | target |
112112
| ports | {ip, target, published, protocol} |
113113

114114
When merging Compose files, Compose appends new entries that do not violate a uniqueness constraint and merge entries that share a unique key.

content/reference/compose-file/services.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,29 @@ configuration, which means for Linux `/etc/hosts` get extra lines:
10051005
::1 myhostv6
10061006
```
10071007

1008+
### `gpus`
1009+
1010+
{{< summary-bar feature_name="Compose gpus" >}}
1011+
1012+
`gpus` specifies GPU devices to be allocated for container usage. This is equivalent to a [device request](deploy.md#devices) with
1013+
an implicit `gpu` capability.
1014+
1015+
```yaml
1016+
services:
1017+
model:
1018+
gpus:
1019+
- driver: 3dfx
1020+
count: 2
1021+
```
1022+
1023+
`gpus` also can be set as string `all` to allocate all available GPU devices to the container.
1024+
1025+
```yaml
1026+
services:
1027+
model:
1028+
gpus: all
1029+
```
1030+
10081031
### `group_add`
10091032

10101033
`group_add` specifies additional groups, by name or number, which the user inside the container must be a member of.

data/summary.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ Compose bridge:
6767
availability: Experimental
6868
Config profiles:
6969
requires: Docker Desktop 4.36 and later
70+
Compose dependent images:
71+
requires: Docker Compose [2.22.0](/manuals/compose/releases/release-notes.md#2220) and later
7072
Compose cgroup:
71-
requires: Docker Compose [2.15.0](/manuals/compose/releases/release-notes.md#2200) and later
73+
requires: Docker Compose [2.15.0](/manuals/compose/releases/release-notes.md#2150) and later
7274
Compose develop:
7375
requires: Docker Compose [2.22.0](/manuals/compose/releases/release-notes.md#2220) and later
7476
Compose driver opts:
@@ -81,6 +83,8 @@ Compose file watch:
8183
requires: Docker Compose [2.22.0](/manuals/compose/releases/release-notes.md#2220) and later
8284
Compose format:
8385
requires: Docker Compose [2.30.0](/manuals/compose/releases/release-notes.md#2300) and later
86+
Compose gpus:
87+
requires: Docker Compose [2.30.0](/manuals/compose/releases/release-notes.md#2300) and later
8488
Compose include:
8589
requires: Docker Compose [2.20.3](/manuals/compose/releases/release-notes.md#2203) and later
8690
Compose label file:

0 commit comments

Comments
 (0)