mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 10:31:46 +04:00
Improving DinD detection
This commit is contained in:
parent
7858ad066f
commit
039db10d86
2 changed files with 43 additions and 7 deletions
|
|
@ -22,7 +22,17 @@ healthy = helpers.basic_healthy
|
|||
def _is_in_docker() -> bool:
|
||||
try:
|
||||
with open('/proc/1/cgroup', 'rb') as f:
|
||||
return b'docker' in f.read()
|
||||
for line in f.readlines():
|
||||
if b'docker' in line:
|
||||
break
|
||||
else:
|
||||
_, name, path = line.strip().split(b':')
|
||||
if name == b'cpuset' and len(os.path.basename(path)) == 64:
|
||||
break
|
||||
else:
|
||||
return False
|
||||
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue