is-docker
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
'is-docker' is a highly useful npm package that allows developers to check if a certain process is running within a Docker container. This package is particularly useful when you want to modify your application's behavior based on the environment it's in.
To use 'is-docker', first, install it in your project using npm with the command npm install is-docker
. Here is an example on how to use 'is-docker' in your JavaScript code:
import isDocker from 'is-docker';
if (isDocker()) {
console.log('Running inside a Docker container');
}
In this code, isDocker()
is a function that returns a boolean value based on whether the application is running inside a Docker container or not.
'is-docker' also provides a CLI command. After it's installed globally or in your project, you can type is-docker
in your terminal. If the shell process is inside a Docker container, the program exits with code 0. Otherwise, it exits with code 2.
The official documentation for 'is-docker' is available directly in its README on its GitHub repository, which can be found at https://github.com/sindresorhus/is-docker. Here you'll find all the necessary instructions and details on how to use this package.