ENGDOCS-2376 (#21797)

<!--Delete sections as needed -->

## Description

Updates Compose Spec with content in
https://github.com/compose-spec/compose-spec/pull/530
Also some freshness of the `ports` attribute

## Related issues or tickets

<!-- Related issues, pull requests, or Jira tickets -->

## Reviews

<!-- Notes for reviewers here -->
<!-- List applicable reviews (optionally @tag reviewers) -->

- [ ] Technical review
- [ ] Editorial review
- [ ] Product review
This commit is contained in:
Allie Sadler 2025-01-13 14:16:37 +00:00 committed by GitHub
parent d08fe30d96
commit dc878e6cd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 14 deletions

View File

@ -1468,7 +1468,7 @@ platform: linux/arm64/v8
> [!NOTE] > [!NOTE]
> >
> Port mapping must not be used with `network_mode: host` otherwise a runtime error occurs. > Port mapping must not be used with `network_mode: host`. Doing so causes a runtime error because `network_mode: host` already exposes container ports directly to the host network, so port mapping isnt needed.
#### Short syntax #### Short syntax
@ -1477,20 +1477,20 @@ in the form:
`[HOST:]CONTAINER[/PROTOCOL]` where: `[HOST:]CONTAINER[/PROTOCOL]` where:
- `HOST` is `[IP:](port | range)` - `HOST` is `[IP:](port | range)` (optional). If it is not set, it binds to all network interfaces (`0.0.0.0`).
- `CONTAINER` is `port | range` - `CONTAINER` is `port | range`.
- `PROTOCOL` to restrict port to specified protocol. `tcp` and `udp` values are defined by the Specification, - `PROTOCOL` restricts ports to a specified protocol either `tcp` or `upd`(optional). Default is `tcp`.
Compose offers support for platform-specific protocol names.
If host IP is not set, it binds to all network interfaces. Ports can be either a single Ports can be either a single value or a range. `HOST` and `CONTAINER` must use equivalent ranges.
value or a range. Host and container must use equivalent ranges.
Either specify both ports (`HOST:CONTAINER`), or just the container port. In the latter case, You can either specify both ports (`HOST:CONTAINER`), or just the container port. In the latter case,
the container runtime automatically allocates any unassigned port of the host. the container runtime automatically allocates any unassigned port of the host.
`HOST:CONTAINER` should always be specified as a (quoted) string, to avoid conflicts `HOST:CONTAINER` should always be specified as a (quoted) string, to avoid conflicts
with [YAML base-60 float](https://yaml.org/type/float.html). with [YAML base-60 float](https://yaml.org/type/float.html).
IPv6 addresses can be enclosed in square brackets.
Examples: Examples:
```yml ```yml
@ -1502,13 +1502,15 @@ ports:
- "49100:22" - "49100:22"
- "8000-9000:80" - "8000-9000:80"
- "127.0.0.1:8001:8001" - "127.0.0.1:8001:8001"
- "127.0.0.1:5000-5010:5000-5010" - "127.0.0.1:5000-5010:5000-5010"
- "6060:6060/udp" - "::1:6000:6000"
- "[::1]:6001:6001"
- "6060:6060/udp"
``` ```
> [!NOTE] > [!NOTE]
> >
> If Host IP mapping is not supported by a container engine, Compose rejects > If host IP mapping is not supported by a container engine, Compose rejects
> the Compose file and ignores the specified host IP. > the Compose file and ignores the specified host IP.
#### Long syntax #### Long syntax
@ -1516,12 +1518,12 @@ ports:
The long form syntax lets you configure additional fields that can't be The long form syntax lets you configure additional fields that can't be
expressed in the short form. expressed in the short form.
- `target`: The container port - `target`: The container port.
- `published`: The publicly exposed port. It is defined as a string and can be set as a range using syntax `start-end`. It means the actual port is assigned a remaining available port, within the set range. - `published`: The publicly exposed port. It is defined as a string and can be set as a range using syntax `start-end`. It means the actual port is assigned a remaining available port, within the set range.
- `host_ip`: The Host IP mapping, unspecified means all network interfaces (`0.0.0.0`). - `host_ip`: The host IP mapping. If it is not set, it binds to all network interfaces (`0.0.0.0`).
- `protocol`: The port protocol (`tcp` or `udp`). Defaults to `tcp`. - `protocol`: The port protocol (`tcp` or `udp`). Defaults to `tcp`.
- `app_protocol`: The application protocol (TCP/IP level 4 / OSI level 7) this port is used for. This is optional and can be used as a hint for Compose to offer richer behavior for protocols that it understands. Introduced in Docker Compose version [2.26.0](/manuals/compose/releases/release-notes.md#2260). - `app_protocol`: The application protocol (TCP/IP level 4 / OSI level 7) this port is used for. This is optional and can be used as a hint for Compose to offer richer behavior for protocols that it understands. Introduced in Docker Compose version [2.26.0](/manuals/compose/releases/release-notes.md#2260).
- `mode`: `host`: For publishing a host port on each node, or `ingress` for a port to be load balanced. Defaults to `ingress`. - `mode`: Specifies how the port is published in a Swarm setup. If set to `host`, it publishes the port on every node in Swarm. If set to `ingress`, it allows load balancing across the nodes in Swarm. Defaults to `ingress`.
- `name`: A human-readable name for the port, used to document it's usage within the service. - `name`: A human-readable name for the port, used to document it's usage within the service.
```yml ```yml