Check if the process is running inside a container
npm install is-inside-container
import isInsideContainer from 'is-inside-container';
if (isInsideContainer()) {
console.log('Running inside a container');
}
is-inside-container
Exits with code 0 if inside a container and 2 if not.
- Docker
- Podman