Reputation: 11512
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.
Upvotes: 8
Views: 1201
Reputation: 9384
According to https://stackoverflow.com/a/25518345/4222206
public boolean isDockerized() {
File f = new File("/.dockerenv");
return f.exists();
}
Upvotes: 4