Skip to content

Commit

Permalink
fix(core): improve docker detection with cgroup
Browse files Browse the repository at this point in the history
./dockerenv may not exist in all docker containers, so we'll check the groups for the running process too
  • Loading branch information
StalkAltan committed Apr 26, 2023
1 parent 2d78de5 commit 9f51eac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/nx/src/daemon/client/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { workspaceRoot } from '../../utils/workspace-root';
import { ChildProcess, spawn } from 'child_process';
import { openSync, readFileSync, statSync } from 'fs';
import { readFileSync, statSync } from 'fs';
import { FileHandle, open } from 'fs/promises';
import { ensureDirSync, ensureFileSync } from 'fs-extra';
import { connect } from 'net';
Expand Down Expand Up @@ -386,6 +386,10 @@ function isDocker() {
statSync('/.dockerenv');
return true;
} catch {
try {
return readFileSync('/proc/self/cgroup', 'utf8')?.includes('docker');
} catch {}

return false;
}
}
Expand Down

0 comments on commit 9f51eac

Please sign in to comment.