From 8ab56c99696f98a8bd6e15974d71db29cf925d20 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Wed, 14 Aug 2024 09:22:19 +0000 Subject: [PATCH] update --- system/host.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/system/host.go b/system/host.go index a13142a..587f228 100644 --- a/system/host.go +++ b/system/host.go @@ -1,6 +1,7 @@ package system import ( + "bufio" "context" "fmt" "os" @@ -125,6 +126,16 @@ func getHostInfo() (string, string, string, string, string, string, string, stri if os.IsExist(err) { VmType = "Docker" } + cgroupFile, err := os.Open("/proc/1/cgroup") + defer cgroupFile.Close() + if err == nil { + scanner := bufio.NewScanner(cgroupFile) + for scanner.Scan() { + if strings.Contains(scanner.Text(), "docker") { + VmType = "Docker" + } + } + } _, err = os.Stat("/dev/lxss") if os.IsExist(err) { VmType = "Windows Subsystem for Linux"