Skip to content
Merged
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
33 changes: 30 additions & 3 deletions content/manuals/compose/how-tos/dependent-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,38 @@ services:
b:
image: service_b
build:
context: b/
dockerfile: b.Dockerfile
additional_contexts:
# `FROM service_a` will be resolved as a dependency on service a which has to be built first
service_a: "service:a"
# `FROM service_a` will be resolved as a dependency on service "a" which has to be built first
service_a: "service:a"
```

With the `additional_contexts` attribute, you can refer to an image built by another service without needing to explicitly name it:

b.Dockerfile:

```dockerfile

FROM base_image
# `base_image` doesn't resolve to an actual image. This is used to point to a named additional context

# build service b
```

Compose file:

```yaml
services:
a:
build:
dockerfile: a.Dockerfile
# built image will be tagged <project_name>_a
b:
build:
dockerfile: b.Dockerfile
additional_contexts:
# `FROM base_image` will be resolved as a dependency on service "a" which has to be built first
base_image: "service:a"
```

## Build with Bake
Expand Down