From 86b71d1dce3ac8a443f826dc9f798e0aebc48492 Mon Sep 17 00:00:00 2001 From: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> Date: Thu, 6 Feb 2025 08:30:20 +0000 Subject: [PATCH 1/2] ENGDOCS-2409 (#21963) ## Description Spec updates: Adds https://github.com/compose-spec/compose-spec/pull/563 Adds https://github.com/compose-spec/compose-spec/pull/558 Adds https://github.com/compose-spec/compose-spec/pull/565 ## Related issues or tickets ## Reviews - [ ] Technical review - [ ] Editorial review - [ ] Product review --- content/reference/compose-file/build.md | 22 +++++++++++++++++++++ content/reference/compose-file/merge.md | 4 ++-- content/reference/compose-file/services.md | 23 ++++++++++++++++++++++ data/summary.yaml | 2 ++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/content/reference/compose-file/build.md b/content/reference/compose-file/build.md index 0a4847fdca76..2b486bde4395 100644 --- a/content/reference/compose-file/build.md +++ b/content/reference/compose-file/build.md @@ -118,6 +118,28 @@ the unused contexts. Illustrative examples of how this is used in Buildx can be found [here](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-additional-build-contexts---build-context). +`additional_contexts` can also refer to an image built by another service. +This allows a service image to be built using another service image as a base image, and to share +layers between service images. + +```yaml +services: + base: + build: + context: . + dockerfile_inline: | + FROM alpine + RUN ... + base: + build: + context: . + dockerfile_inline: | + FROM base # image built for service base + RUN ... + additional_contexts: + base: service:base +``` + ### `args` `args` define build arguments, that is Dockerfile `ARG` values. diff --git a/content/reference/compose-file/merge.md b/content/reference/compose-file/merge.md index 321320fc6548..ccd0390b003b 100644 --- a/content/reference/compose-file/merge.md +++ b/content/reference/compose-file/merge.md @@ -107,8 +107,8 @@ While these types are modeled in a Compose file as a sequence, they have special | Attribute | Unique key | |-------------|--------------------------| | volumes | target | -| secrets | source | -| configs | source | +| secrets | target | +| configs | target | | ports | {ip, target, published, protocol} | When merging Compose files, Compose appends new entries that do not violate a uniqueness constraint and merge entries that share a unique key. diff --git a/content/reference/compose-file/services.md b/content/reference/compose-file/services.md index c4ce1d542b54..1e21cbde7962 100644 --- a/content/reference/compose-file/services.md +++ b/content/reference/compose-file/services.md @@ -1005,6 +1005,29 @@ configuration, which means for Linux `/etc/hosts` get extra lines: ::1 myhostv6 ``` +### `gpus` + +{{< summary-bar feature_name="Compose gpus" >}} + +`gpus` specifies GPU devices to be allocated for container usage. This is equivalent to a [device request](deploy.md#devices) with +an implicit `gpu` capability. + +```yaml +services: + model: + gpus: + - driver: 3dfx + count: 2 +``` + +`gpus` also can be set as string `all` to allocate all available GPU devices to the container. + +```yaml +services: + model: + gpus: all +``` + ### `group_add` `group_add` specifies additional groups, by name or number, which the user inside the container must be a member of. diff --git a/data/summary.yaml b/data/summary.yaml index b7cfa2076309..a5aace9f8a55 100644 --- a/data/summary.yaml +++ b/data/summary.yaml @@ -81,6 +81,8 @@ Compose file watch: requires: Docker Compose [2.22.0](/manuals/compose/releases/release-notes.md#2220) and later Compose format: requires: Docker Compose [2.30.0](/manuals/compose/releases/release-notes.md#2300) and later +Compose gpus: + requires: Docker Compose [2.30.0](/manuals/compose/releases/release-notes.md#2300) and later Compose include: requires: Docker Compose [2.20.3](/manuals/compose/releases/release-notes.md#2203) and later Compose label file: From 4e1eb2942ab40c83d24ba81aea885d4147840f9b Mon Sep 17 00:00:00 2001 From: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> Date: Thu, 6 Feb 2025 08:30:33 +0000 Subject: [PATCH 2/2] add shortcode (#21972) ## Description Adds shortcode and renames the page (have not added an alias as the page has been live for less than 24 hours so does not need one) ## Related issues or tickets ## Reviews - [ ] Technical review - [ ] Editorial review - [ ] Product review --- .../how-tos/{depent-images.md => dependent-images.md} | 6 ++---- data/summary.yaml | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) rename content/manuals/compose/how-tos/{depent-images.md => dependent-images.md} (98%) diff --git a/content/manuals/compose/how-tos/depent-images.md b/content/manuals/compose/how-tos/dependent-images.md similarity index 98% rename from content/manuals/compose/how-tos/depent-images.md rename to content/manuals/compose/how-tos/dependent-images.md index 005cba4cbae9..a8a462539c9b 100644 --- a/content/manuals/compose/how-tos/depent-images.md +++ b/content/manuals/compose/how-tos/dependent-images.md @@ -5,6 +5,8 @@ title: Build dependent images weight: 50 --- +{{< summary-bar feature_name="Compose dependent images" >}} + To reduce push/pull time and image weight, a common practice for Compose applications is to have services share base layers as much as possible. You will typically select the same operating system base image for 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`. The recommended approach is to group the shared declaration in a single Dockerfile, and use multi-stage features so that service images are built from this shared declaration. - Dockerfile: ```dockerfile @@ -53,7 +54,6 @@ A popular pattern is to reuse a service image as a base image in another service As Compose does not parse the Dockerfile, it can't automatically detect this dependency between services to correctly order the build execution. - a.Dockerfile: ```dockerfile @@ -82,7 +82,6 @@ services: dockerfile: b.Dockerfile ``` - Legacy Docker Compose v1 used to build images sequentially, which made this pattern usable out of the box. Compose v2 uses BuildKit to optimise builds and build images in parallel and requires an explicit declaration. @@ -107,7 +106,6 @@ services: service_a: "service:a" ``` - ## Build with Bake Using [Bake](/manuals/build/bake/_index.md) let you pass the complete build definition for all services diff --git a/data/summary.yaml b/data/summary.yaml index a5aace9f8a55..aadee7d65a7a 100644 --- a/data/summary.yaml +++ b/data/summary.yaml @@ -67,8 +67,10 @@ Compose bridge: availability: Experimental Config profiles: requires: Docker Desktop 4.36 and later +Compose dependent images: + requires: Docker Compose [2.22.0](/manuals/compose/releases/release-notes.md#2220) and later Compose cgroup: - requires: Docker Compose [2.15.0](/manuals/compose/releases/release-notes.md#2200) and later + requires: Docker Compose [2.15.0](/manuals/compose/releases/release-notes.md#2150) and later Compose develop: requires: Docker Compose [2.22.0](/manuals/compose/releases/release-notes.md#2220) and later Compose driver opts: