You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!--Delete sections as needed -->
## Description
Updates Compose Spec with content in
compose-spec/compose-spec#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
Copy file name to clipboardExpand all lines: content/reference/compose-file/services.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1468,7 +1468,7 @@ platform: linux/arm64/v8
1468
1468
1469
1469
> [!NOTE]
1470
1470
>
1471
-
> Port mapping must not be used with `network_mode: host` otherwise a runtime error occurs.
1471
+
> 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 isn’t needed.
1472
1472
1473
1473
#### Short syntax
1474
1474
@@ -1477,20 +1477,20 @@ in the form:
1477
1477
1478
1478
`[HOST:]CONTAINER[/PROTOCOL]` where:
1479
1479
1480
-
- `HOST`is `[IP:](port | range)`
1481
-
- `CONTAINER`is `port | range`
1482
-
- `PROTOCOL`to restrict port to specified protocol. `tcp` and `udp` values are defined by the Specification,
1483
-
Compose offers support for platform-specific protocol names.
1480
+
- `HOST`is `[IP:](port | range)` (optional). If it is not set, it binds to all network interfaces (`0.0.0.0`).
1481
+
- `CONTAINER`is `port | range`.
1482
+
- `PROTOCOL`restricts ports to a specified protocol either `tcp` or `upd`(optional). Default is `tcp`.
1484
1483
1485
-
If host IP is not set, it binds to all network interfaces. Ports can be either a single
1486
-
value or a range. Host and container must use equivalent ranges.
1484
+
Ports can be either a single value or a range. `HOST` and `CONTAINER` must use equivalent ranges.
1487
1485
1488
-
Either specify both ports (`HOST:CONTAINER`), or just the container port. In the latter case,
1486
+
You can either specify both ports (`HOST:CONTAINER`), or just the container port. In the latter case,
1489
1487
the container runtime automatically allocates any unassigned port of the host.
1490
1488
1491
1489
`HOST:CONTAINER`should always be specified as a (quoted) string, to avoid conflicts
1492
1490
with [YAML base-60 float](https://yaml.org/type/float.html).
1493
1491
1492
+
IPv6 addresses can be enclosed in square brackets.
1493
+
1494
1494
Examples:
1495
1495
1496
1496
```yml
@@ -1502,26 +1502,28 @@ ports:
1502
1502
- "49100:22"
1503
1503
- "8000-9000:80"
1504
1504
- "127.0.0.1:8001:8001"
1505
-
- "127.0.0.1:5000-5010:5000-5010"
1506
-
- "6060:6060/udp"
1505
+
- "127.0.0.1:5000-5010:5000-5010"
1506
+
- "::1:6000:6000"
1507
+
- "[::1]:6001:6001"
1508
+
- "6060:6060/udp"
1507
1509
```
1508
1510
1509
1511
> [!NOTE]
1510
1512
>
1511
-
> If Host IP mapping is not supported by a container engine, Compose rejects
1513
+
> If host IP mapping is not supported by a container engine, Compose rejects
1512
1514
> the Compose file and ignores the specified host IP.
1513
1515
1514
1516
#### Long syntax
1515
1517
1516
1518
The long form syntax lets you configure additional fields that can't be
1517
1519
expressed in the short form.
1518
1520
1519
-
- `target`: The container port
1521
+
- `target`: The container port.
1520
1522
- `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.
1521
-
- `host_ip`: The Host IP mapping, unspecified means all network interfaces (`0.0.0.0`).
1523
+
- `host_ip`: The host IP mapping. If it is not set, it binds to all network interfaces (`0.0.0.0`).
1522
1524
- `protocol`: The port protocol (`tcp` or `udp`). Defaults to `tcp`.
1523
1525
- `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).
1524
-
- `mode`: `host`: For publishing a hostport on each node, or `ingress` for a port to be load balanced. Defaults to `ingress`.
1526
+
- `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`.
1525
1527
- `name`: A human-readable name for the port, used to document it's usage within the service.
0 commit comments