#process-running #container #docker

bin+lib is-container

Check if the process is running inside a container

2 releases

0.1.2 Mar 18, 2023
0.1.1 Mar 18, 2023
0.1.0 Mar 14, 2023

#947 in Unix APIs

29 downloads per month

MIT license

4KB

is-container

Check if the process is running inside a container.

Lib

$ cargo add is-container
use is_container::is_container;

if is_container() {
    println!("Running inside a container");
}

CLI

$ cargo install is-container
$ is-container

# Exits with code 0 if inside a container and 2 if not.
$ echo $?
2

lib.rs:

Check if the process is running inside a container.

Examples

use is_container::is_container;

if is_container() {
    println!("Running inside a container");
}

Inspired

Dependencies

~48KB