From 4f0e2d82b31068547f165872944fcbcecd4b3d52 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Wed, 3 Jul 2024 12:43:13 -0700 Subject: [PATCH] feat(config): check pid for container startup (#1589) fix(config): check pid for container startup --- internal/config/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index cc0412e..486a40f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -116,6 +116,11 @@ func (c *AppConfig) writeConfig(configPath string, configFile string) error { // if this file exists then the viewer is running // from inside a lxc container so return true host = "0.0.0.0" + } else if os.Getpid() == 1 { + // if we're running as pid 1, we're honoured. + // but there's a good chance this is an isolated namespace + // or a container. + host = "0.0.0.0" } else if pd, _ := os.Open("/proc/1/cgroup"); pd != nil { defer pd.Close() b := make([]byte, 4096)