Add fallback method for checking docker.
This commit is contained in:
parent
d336e94546
commit
eb5fc74e08
1 changed files with 8 additions and 9 deletions
|
@ -5,15 +5,14 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class EnvironmentUtils
|
||||
{
|
||||
public static boolean isRunningInsideDocker()
|
||||
{
|
||||
try{
|
||||
Stream<String> str = Files.lines ( Paths.get ( "/proc/1/cgroup" ) );
|
||||
return str.anyMatch ( ln->ln.contains ( "/docker" ) );
|
||||
}catch( IOException e )
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue