mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-08 09:07:44 +00:00
hostinfo: detect being run in a container in more ways
Change-Id: I038ff7705ba232e6cf8dcc9775357ef708d43762 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
d5e7e3093d
commit
16939f0d56
@ -229,6 +229,15 @@ func inContainer() opt.Bool {
|
|||||||
}
|
}
|
||||||
var ret opt.Bool
|
var ret opt.Bool
|
||||||
ret.Set(false)
|
ret.Set(false)
|
||||||
|
if _, err := os.Stat("/.dockerenv"); err == nil {
|
||||||
|
ret.Set(true)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
if _, err := os.Stat("/run/.containerenv"); err == nil {
|
||||||
|
// See https://github.com/cri-o/cri-o/issues/5461
|
||||||
|
ret.Set(true)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
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/")) ||
|
||||||
mem.Contains(mem.B(line), mem.S("/lxc/")) {
|
mem.Contains(mem.B(line), mem.S("/lxc/")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user