Crates.io | in-container |
lib.rs | in-container |
version | 1.1.0 |
source | src |
created_at | 2020-07-17 17:24:11.372358 |
updated_at | 2022-01-29 15:40:15.272324 |
description | Determines if it is running in a container |
homepage | https://github.com/pitkley/in-container |
repository | https://github.com/pitkley/in-container.git |
max_upload_size | |
id | 266299 |
size | 36,367 |
in-container
is a binary and a library that can be used to detect if you are running inside a container.
Executing the binary will by default return exit-code 0 if it was run inside a container and exit-code 1 if it wasn't.
The library can be included in an application of your choice, allowing you to determine whether your application is running inside a container or not.
(Please note that some of the detection mechanisms only work if in-container
is executed in a privileged context.)
If you are missing support for an operating system or container runtime, feel free to open a feature request or open a pull request.
Add in-container
as a dependency to your project's Cargo.toml
:
[dependencies]
in-container = { version = "^1", default-features = false }
You can then use in_container::in_container()
which will return true
if you are running inside a container and false
otherwise.
In case you are interested in the container-runtime that was detected, you can call in_container::get_container_runtime()
instead, which will return an Option<ContainerRuntime>
.
The Option
is None
when not running in a container, otherwise it will contain the detected runtime.
In general, the versioning scheme follows the semantic versioning guidelines:
Special case:
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.