Skip to content

Commit

Permalink
Fix: 优化 is_in_container 函数(#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
clq321 committed Jul 9, 2024
1 parent 84e8bb6 commit d129ec7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ function delete_cache(string $prefix, array $args): void
if (! function_exists('is_in_container')) {
function is_in_container(): bool
{
if (! file_exists('/proc/self/mountinfo')) {
return false;
if (file_exists('/.dockerenv')) {
return true;
}
$mountinfo = file_get_contents('/proc/self/mountinfo');
return strpos($mountinfo, 'kubepods') > 0 || strpos($mountinfo, 'docker') > 0;
$cgroup = file_get_contents('/proc/1/cgroup');
return strpos($cgroup, 'kubepods') > 0 || strpos($cgroup, 'docker') > 0;
}
}

Expand Down

0 comments on commit d129ec7

Please sign in to comment.