浏览代码

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.
Andy 2 年之前
父节点
当前提交
325fd01ebb
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      nginx.tmpl

+ 5 - 0
nginx.tmpl

@@ -67,6 +67,11 @@
     #         {{ .Name }} (ignored)
     #         {{ .Name }} (ignored)
             {{- continue }}
             {{- continue }}
         {{- end }}
         {{- 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) }}
         {{- if and (not (index $.globals.networks .Name)) (not $.globals.networks.host) }}
     #         {{ .Name }} (unreachable)
     #         {{ .Name }} (unreachable)
             {{- continue }}
             {{- continue }}