[英]Is there any way, from inside a Java program, to detect if its running in a Docker?
Title says it.标题说了算。 I'm running a Java program, and from within the program I'd like to detect whether its running inside a Docker container or not.
我正在运行一个 Java 程序,我想从程序内部检测它是否在 Docker 容器中运行。
According to https://stackoverflow.com/a/25518345/4222206根据https://stackoverflow.com/a/25518345/4222206
public boolean isDockerized() {
File f = new File("/.dockerenv");
return f.exists();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.