From 325fd01ebbbe8af8fb684819e3db58dcc9c3091b Mon Sep 17 00:00:00 2001 From: Andy <59445582+rot169@users.noreply.github.com> Date: Sun, 23 Apr 2023 14:09:33 +0100 Subject: [PATCH] Support containers running --net=host (#1537) Detect if a target container is running host networking, and if so, use the IP address of the first bridge net gateway. --- nginx.tmpl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nginx.tmpl b/nginx.tmpl index 2556acf..f322db9 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -67,6 +67,11 @@ # {{ .Name }} (ignored) {{- continue }} {{- end }} + {{- if eq .Name "host" }} + # {{ .Name }} (host network; using {{ (index $.globals.CurrentContainer.Networks 0).Name }} gateway) + {{- $ip = (index $.globals.CurrentContainer.Networks 0).Gateway }} + {{- continue }} + {{- end }} {{- if and (not (index $.globals.networks .Name)) (not $.globals.networks.host) }} # {{ .Name }} (unreachable) {{- continue }}