MCPcopy
hub / github.com/dataelement/Clawith / _running_in_container

Function _running_in_container

backend/app/config.py:14–28  ·  view source on GitHub ↗

Best-effort container runtime detection.

()

Source from the content-addressed store, hash-verified

12
13
14def _running_in_container() -> bool:
15 """Best-effort container runtime detection."""
16 if Path("/.dockerenv").exists() or Path("/run/.containerenv").exists():
17 return True
18
19 cgroup = Path("/proc/1/cgroup")
20 if not cgroup.exists():
21 return False
22
23 try:
24 content = cgroup.read_text(encoding="utf-8", errors="ignore")
25 except OSError:
26 return False
27
28 return any(token in content for token in ("docker", "containerd", "kubepods", "podman"))
29
30
31def _default_agent_data_dir() -> str:

Calls 2

read_textMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected