This repository has been archived on 2024-10-31. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
LibZontreck/src/main/java/dev/zontreck/ariaslib/util/EnvironmentUtils.java
2024-10-09 22:21:30 -07:00

19 lines
503 B
Java

package dev.zontreck.ariaslib.util;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;
public class EnvironmentUtils {
public static boolean isRunningInsideDocker ( ) {
if ( Files.exists ( Paths.get ( "/.dockerenv" ) ) )
return true;
try {
Stream<String> str = Files.lines ( Paths.get ( "/proc/1/cgroup" ) );
return str.anyMatch ( ln -> ln.contains ( "/docker" ) );
} catch ( IOException e ) {
return false;
}
}
}