Package org.apache.commons.lang3
Class RuntimeEnvironment
- java.lang.Object
-
- org.apache.commons.lang3.RuntimeEnvironment
-
public class RuntimeEnvironment extends java.lang.ObjectHelps query the runtime environment.- Since:
- 3.15.0
-
-
Constructor Summary
Constructors Constructor Description RuntimeEnvironment()Deprecated.Will be removed in 4.0.0.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.BooleaninContainer()Tests whether we are running in a container like Docker or Podman.
-
-
-
Method Detail
-
inContainer
public static java.lang.Boolean inContainer()
Tests whether we are running in a container like Docker or Podman.The following may change if we find better detection logic.
We roughly follow the logic in SystemD:
We check the `container` environment variable of process 1:
- If the variable is empty, we return false. This includes the case, where the container developer wants to hide the fact that the application runs in a container.
- If the variable is not empty, we return true.
- If the variable is absent, we continue.
- We check files in the container. According to SystemD:/
- /.dockerenv is used by Docker.
- /run/.containerenv is used by PodMan.
- Returns:
- whether we are running in a container like Docker or Podman. Never null.
- See Also:
- SystemD virt.c
-
-