From 3ba53df00517ff5e01d4369e535b9776f16f62b6 Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Mon, 29 Jul 2024 10:22:04 +0200 Subject: [PATCH] Document Docker port selection on multiple exposed ports --- docs/content/providers/docker.md | 10 ++++++---- docs/content/routing/providers/docker.md | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/content/providers/docker.md b/docs/content/providers/docker.md index d47e9d78f..5202dfe32 100644 --- a/docs/content/providers/docker.md +++ b/docs/content/providers/docker.md @@ -117,12 +117,14 @@ When using Docker Compose, labels are specified by the directive Traefik retrieves the private IP and port of containers from the Docker API. -Port detection works as follows: +Port detection for private communication works as follows: - If a container [exposes](https://docs.docker.com/engine/reference/builder/#expose) a single port, - then Traefik uses this port for private communication. + then Traefik uses this port. - If a container [exposes](https://docs.docker.com/engine/reference/builder/#expose) multiple ports, - or does not expose any port, then you must manually specify which port Traefik should use for communication + then Traefik uses the lowest port. E.g. if `80` and `8080` are exposed, Traefik will use `80`. +- If a container does not expose any port, or the selection from multiple ports does not fit, + then you must manually specify which port Traefik should use for communication by using the label `traefik.http.services..loadbalancer.server.port` (Read more on this label in the dedicated section in [routing](../routing/providers/docker.md#port)). @@ -738,7 +740,7 @@ providers: _Optional, Default=false_ If the parameter is set to `true`, -any [servers load balancer](../routing/services/index.md#servers-load-balancer) defined for Docker containers is created +any [servers load balancer](../routing/services/index.md#servers-load-balancer) defined for Docker containers is created regardless of the [healthiness](https://docs.docker.com/engine/reference/builder/#healthcheck) of the corresponding containers. It also then stays alive and responsive even at times when it becomes empty, i.e. when all its children containers become unhealthy. diff --git a/docs/content/routing/providers/docker.md b/docs/content/routing/providers/docker.md index b120abbb7..1c30f7824 100644 --- a/docs/content/routing/providers/docker.md +++ b/docs/content/routing/providers/docker.md @@ -66,10 +66,11 @@ With Docker, Traefik can leverage labels attached to a container to generate rou ``` !!! important "Traefik Connecting to the Wrong Port: `HTTP/502 Gateway Error`" - By default, Traefik uses the first exposed port of a container. + By default, Traefik uses the lowest exposed port of a container as detailed in + [Port Detection](../providers/docker.md#port-detection) of the Docker provider. Setting the label `traefik.http.services.xxx.loadbalancer.server.port` - overrides that behavior. + overrides this behavior. ??? example "Specifying more than one router and service per container"