is-docker

Check if the process is running inside a Docker container

MIT 10 个版本
安装
npm install is-docker
yarn add is-docker
pnpm add is-docker
bun add is-docker
README

is-docker

Check if the process is running inside a Docker container

Install

npm install is-docker

Usage

import isDocker from 'is-docker';

if (isDocker()) {
	console.log('Running inside a Docker container');
}

CLI

$ is-docker

Exits with code 0 if inside a Docker container and 2 if not.

$ is-docker && echo "Running in Docker" || echo "Not running in Docker"
版本列表
4.0.0 2025-09-15
3.0.0 2021-08-31
2.2.1 2021-04-09
2.2.0 2021-04-05
2.1.1 2020-08-04
2.1.0 2020-08-02
2.0.0 2019-04-19
1.1.0 2016-10-27
1.0.1 2016-05-18
1.0.0 2015-04-08