Skip to main content

is_container

Function is_container 

Source
pub fn is_container() -> bool
Expand description

Returns true if the current process appears to be running inside a container.

See the crate-level documentation for the algorithm and the supported platforms, and for the important assumption that this crate is not used by code that may legitimately run as PID 1 on the host kernel.

The result is computed once and cached for the remainder of the process; subsequent calls return the cached value.

ยงExamples

let in_container = detect_container::is_container();
println!("in container: {in_container}");