Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Aug 14, 2024
1 parent 6031bf8 commit 8ab56c9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions system/host.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package system

import (
"bufio"
"context"
"fmt"
"os"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8ab56c9

Please sign in to comment.