From f85f3b68aaf660e26296e99d97f134950d1e1cb8 Mon Sep 17 00:00:00 2001 From: Adrian Freund Date: Tue, 19 Jul 2022 16:22:08 +0200 Subject: [PATCH] Add support for reaching containers using host networking on Podman --- docs/content/providers/docker.md | 3 ++- pkg/provider/docker/config.go | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/content/providers/docker.md b/docs/content/providers/docker.md index cdb323527..3b6de478f 100644 --- a/docs/content/providers/docker.md +++ b/docs/content/providers/docker.md @@ -133,7 +133,8 @@ the IP address of the host is resolved as follows: - try a lookup of `host.docker.internal` -- if the lookup was unsuccessful, fall back to `127.0.0.1` +- if the lookup was unsuccessful, try a lookup of `host.containers.internal`, ([Podman](https://docs.podman.io/en/latest/) equivalent of `host.docker.internal`) +- if that lookup was also unsuccessful, fall back to `127.0.0.1` On Linux, for versions of Docker older than 20.10.0, for `host.docker.internal` to be defined, it should be provided as an `extra_host` to the Traefik container, using the `--add-host` flag. For example, to set it to the IP address of diff --git a/pkg/provider/docker/config.go b/pkg/provider/docker/config.go index 9de876c63..f5e0d8125 100644 --- a/pkg/provider/docker/config.go +++ b/pkg/provider/docker/config.go @@ -338,6 +338,9 @@ func (p Provider) getIPAddress(ctx context.Context, container dockerData) string if host, err := net.LookupHost("host.docker.internal"); err == nil { return host[0] } + if host, err := net.LookupHost("host.containers.internal"); err == nil { + return host[0] + } return "127.0.0.1" }