insideContainer function

bool insideContainer()

Returns true when the current process is running inside a Docker container.

Detection strategy: checks for the existence of /.dockerenv, which Docker places in every container's root filesystem.

Returns false on any I/O error and on non-Linux platforms where the file is unlikely to exist.

Implementation

bool insideContainer() => File('/.dockerenv').existsSync();