realityone / container-what

Detect if we are running in a container.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

container-what

Build Status

Detect if we are running in a container.

Looks like virt-what, but aim to container engines.

More container engines will be added.

Installation

Put this crate in your Cargo.toml.

[dependencies]
container-what = "*"

Usage

extern crate container_what;

use std::path::Path;

use container_what::container::ContainerEngine;
use container_what::common::{Detector, DetectorContext};
use container_what::container::detector::ContainerDetector;


fn main() {
    // Specify the detect root
    let ref ctx = DetectorContext::new(Path::new("/"));
    assert_eq!(ContainerDetector::detect(ctx), ContainerEngine::Docker);
}

License

container-what is licensed under the MIT License - see the LICENSE file for details

About

Detect if we are running in a container.

License:MIT License


Languages

Language:Rust 95.3%Language:Shell 4.7%