Skip to content

Compose: spec updates #22655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions _vale/config/vocabularies/Docker/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Zsh
[Ss]warm
[Ss]yscalls?
[Ss]ysfs
[Tt]eardown
[Tt]oolchains?
[Uu]narchived?
[Uu]ngated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This page contains information on how you can set or change the following pre-de
- `COMPOSE_ENV_FILES`
- `COMPOSE_MENU`
- `COMPOSE_EXPERIMENTAL`
- `COMPOSE_PROGRESS`

## Methods to override

Expand Down Expand Up @@ -192,6 +193,15 @@ This is an opt-out variable. When turned off it deactivates the experimental fea
- `false` or `0`, to disable
- Defaults to: `1`

### COMPOSE\_PROGRESS

{{< summary-bar feature_name="Compose progress" >}}

Defines the type of progress output, if `--progress` isn't used.

Supported values are `auto`, `tty`, `plain`, `json`, and `quiet`.
Default is `auto`.

## Unsupported in Compose V2

The following environment variables have no effect in Compose V2.
Expand Down
11 changes: 8 additions & 3 deletions content/reference/compose-file/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,7 @@ The long syntax provides more granularity in how the secret is created within
the service's containers.

- `source`: The name of the secret as it exists on the platform.
- `target`: The name of the file to be mounted in `/run/secrets/` in the
service's task containers. Defaults to `source` if not specified.
- `target`: The ID of the secret as declared in the Dockerfile. Defaults to `source` if not specified.
- `uid` and `gid`: The numeric uid or gid that owns the file within
`/run/secrets/` in the service's task containers. Default value is `USER`.
- `mode`: The [permissions](https://wintelguy.com/permissions-calc.pl) for the file to be mounted in `/run/secrets/`
Expand All @@ -487,7 +486,7 @@ services:
context: .
secrets:
- source: server-certificate
target: server.cert
target: cert # secret ID in Dockerfile
uid: "103"
gid: "103"
mode: 0440
Expand All @@ -496,6 +495,12 @@ secrets:
external: true
```

```dockerfile
# Dockerfile
FROM nginx
RUN --mount=type=secret,id=cert,required=true,target=/root/cert ...
```

Service builds may be granted access to multiple secrets. Long and short syntax for secrets may be used in the
same Compose file. Defining a secret in the top-level `secrets` must not imply granting any service build access to it.
Such grant must be explicit within service specification as [secrets](services.md#secrets) service element.
Expand Down
77 changes: 71 additions & 6 deletions content/reference/compose-file/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -1395,9 +1395,31 @@ services:
- mysql
networks:
front-tier:
back-tier:
admin:
front-tier: {}
back-tier: {}
admin: {}
```

### `interface_name`

{{< summary-bar feature_name="Compose interface-name" >}}

`interface_name` lets you specify the name of the network interface used to connect a service to a given network. This ensures consistent and predictable interface naming across services and networks.

```yaml
services:
backend:
image: alpine
command: ip link show
networks:
back-tier:
interface_name: eth0
```

Running the example Compose application shows:

```console
backend-1 | 11: eth0@if64: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
```

#### `ipv4_address`, `ipv6_address`
Expand Down Expand Up @@ -1693,6 +1715,46 @@ services:
- debug
```

### `provider`

{{< summary-bar feature_name="Compose provider services" >}}

`provider` can be used to define a service that Compose won't manage directly. Compose delegated the service lifecycle to a dedicated or third-party component.

```yaml
database:
provider:
type: awesomecloud
options:
type: mysql
foo: bar
app:
image: myapp
depends_on:
- database
```

As Compose runs the application, the `awesomecloud` binary is used to manage the `database` service setup.
Dependent service `app` receives additional environment variables prefixed by the service name so it can access the resource.

For illustration, assuming `awesomecloud` execution produced variables `URL` and `API_KEY`, the `app` service
runs with environment variables `DATABASE_URL` and `DATABASE_API_KEY`.

As Compose stops the application, the `awesomecloud` binary is used to manage the `database` service tear down.

The mechanism used by Compose to delegate the service lifecycle to an external binary is described [here](https://github.com/docker/compose/tree/main/docs/extension.md).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit iffy. But need to figure this out next week with the Compose team so keeping as-is for now.


For more information on using the `provider` attribute, see [Use provider services](/manuals/compose/how-tos/provider-services.md).

### `type`

`type` attribute is required. It defines the external component used by Compose to manage setup and tear down lifecycle
events.

### `options`

`options` are specific to the selected provider and not validated by the compose specification

### `pull_policy`

`pull_policy` defines the decisions Compose makes when it starts to pull images. Possible values are:
Expand Down Expand Up @@ -2035,6 +2097,11 @@ The short syntax uses a single string with colon-separated values to specify a v
> platform it rejects Compose files which use relative host paths with an error. To avoid ambiguities
> with named volumes, relative paths should always begin with `.` or `..`.

> [!NOTE]
>
> For bind mounts, the short syntax creates a directory at the source path on the host if it doesn't exist. This is for backward compatibility with `docker-compose` legacy.
> It can be prevented by using long syntax and setting `create_host_path` to `false`.

#### Long syntax

The long form syntax lets you configure additional fields that can't be
Expand All @@ -2048,9 +2115,7 @@ expressed in the short form.
- `read_only`: Flag to set the volume as read-only.
- `bind`: Used to configure additional bind options:
- `propagation`: The propagation mode used for the bind.
- `create_host_path`: Creates a directory at the source path on host if there is nothing present.
Compose does nothing if there is something present at the path. This is automatically implied by short syntax
for backward compatibility with `docker-compose` legacy.
- `create_host_path`: Creates a directory at the source path on host if there is nothing present. Defaults to `true`.
- `selinux`: The SELinux re-labeling option `z` (shared) or `Z` (private)
- `volume`: Configures additional volume options:
- `nocopy`: Flag to disable copying of data from a container when a volume is created.
Expand Down
4 changes: 4 additions & 0 deletions data/summary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Compose gw priority:
requires: Docker Compose [2.33.1](/manuals/compose/releases/release-notes.md#2331) and later
Compose include:
requires: Docker Compose [2.20.3](/manuals/compose/releases/release-notes.md#2203) and later
Compose interface-name:
requires: Docker Compose [2.36.0](/manuals/compose/releases/release-notes.md#2203) and later
Compose label file:
requires: Docker Compose [2.32.2](/manuals/compose/releases/release-notes.md#2232) and later
Compose lifecycle hooks:
Expand All @@ -111,6 +113,8 @@ Compose OCI artifact:
requires: Docker Compose [2.34.0](/manuals/compose/releases/release-notes.md#2340) and later
Compose provider services:
requires: Docker Compose [2.36.0](/manuals/compose/releases/release-notes.md) and later
Compose progress:
requires: Docker Compose [2.36.0](/manuals/compose/releases/release-notes.md) and later
Compose replace file:
requires: Docker Compose [2.24.4](/manuals/compose/releases/release-notes.md#2244) and later
Compose required:
Expand Down