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.nio.file.Paths;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class EnvironmentUtils
|
public class EnvironmentUtils {
|
||||||
{
|
public static boolean isRunningInsideDocker ( ) {
|
||||||
public static boolean isRunningInsideDocker()
|
if ( Files.exists ( Paths.get ( "/.dockerenv" ) ) )
|
||||||
{
|
return true;
|
||||||
try{
|
try {
|
||||||
Stream<String> str = Files.lines ( Paths.get ( "/proc/1/cgroup" ) );
|
Stream<String> str = Files.lines ( Paths.get ( "/proc/1/cgroup" ) );
|
||||||
return str.anyMatch ( ln->ln.contains ( "/docker" ) );
|
return str.anyMatch ( ln -> ln.contains ( "/docker" ) );
|
||||||
}catch( IOException e )
|
} catch ( IOException e ) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue