mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-05 16:05:36 +00:00
hostinfo: detect being run in a container in more ways
Change-Id: I038ff7705ba232e6cf8dcc9775357ef708d43762
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
(cherry picked from commit 16939f0d56
)
This commit is contained in:
parent
facdc475bb
commit
0345649d05
@ -183,6 +183,13 @@ func inContainer() bool {
|
|||||||
if runtime.GOOS != "linux" {
|
if runtime.GOOS != "linux" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if _, err := os.Stat("/.dockerenv"); err == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if _, err := os.Stat("/run/.containerenv"); err == nil {
|
||||||
|
// See https://github.com/cri-o/cri-o/issues/5461
|
||||||
|
return true
|
||||||
|
}
|
||||||
var ret bool
|
var ret bool
|
||||||
lineread.File("/proc/1/cgroup", func(line []byte) error {
|
lineread.File("/proc/1/cgroup", func(line []byte) error {
|
||||||
if mem.Contains(mem.B(line), mem.S("/docker/")) ||
|
if mem.Contains(mem.B(line), mem.S("/docker/")) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user