Skip to content

Commit 21f548f

Browse files
chubi-xaevesdocker
andauthored
Update ports section in services.md (#22368)
Explicitly state the dangers if a port mapping binds to all interfaces ## Description <!-- Tell us what you did and why --> We recently discovered that docker was bypassing our firewall rules when forwarding ports from a container using the standard `<host port>:<container port>` syntax. What this meant was that the container was effectively visible to the entire internet. It was only after some digging did we discover that it is possible and even recommended to explicitly bind the host port to localhost so it doesn't accept connections from everywhere. This PR updates the docs to explicitly state the potential dangers of not specifying a localhost when exposing docker container ports. ## Reviews - [ ] Technical review - [ ] Editorial review - [ ] Product review --------- Co-authored-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com>
1 parent 5c73210 commit 21f548f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

content/reference/compose-file/services.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,10 @@ in the form:
16511651
- `CONTAINER` is `port | range`.
16521652
- `PROTOCOL` restricts ports to a specified protocol either `tcp` or `udp`(optional). Default is `tcp`.
16531653

1654+
> [!WARNING]
1655+
>
1656+
> If you do not specify a host IP (such as `127.0.0.1`), Docker binds to all interfaces (`0.0.0.0`), bypassing host firewall rules. This can expose the container directly to the internet if the host has a public IP address. For more information, see [Port publishing and mapping](/manuals/engine/network/port-publishing.md).
1657+
16541658
Ports can be either a single value or a range. `HOST` and `CONTAINER` must use equivalent ranges.
16551659

16561660
You can either specify both ports (`HOST:CONTAINER`), or just the container port. In the latter case,
@@ -1659,6 +1663,8 @@ the container runtime automatically allocates any unassigned port of the host.
16591663
`HOST:CONTAINER` should always be specified as a (quoted) string, to avoid conflicts
16601664
with [YAML base-60 float](https://yaml.org/type/float.html).
16611665

1666+
1667+
16621668
IPv6 addresses can be enclosed in square brackets.
16631669

16641670
Examples:

0 commit comments

Comments
 (0)