import fs from "fs" ; function hasDockerEnv ( ) { try { fs . statSync ( "/.dockerenv" ) ; return true ; } catch { return false ; } } function hasDockerCGroup ( ) { try { return fs . readFileSync ( "/proc/self/cgroup" , "utf8" ) . includes ( "docker" ) ; } catch { return false ; } } let _isDocker ; /** Check if the process is running inside a Docker container */ export function isDocker ( ) { if ( _isDocker === undefined ) { _isDocker = hasDockerEnv ( ) || hasDockerCGroup ( ) ; } return _isDocker ; }