Skip to content

Commit 9746af5

Browse files
committed
ENGDOCS-2409
1 parent 325da94 commit 9746af5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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.

0 commit comments

Comments
 (0)