AllowUstoGetContainerInfoOnDocker

Tested on docker. Although "/proc/self/cgroup" file is not empty, "/proc/self/cgroup".toFile().length() returns 0
as does Files.size("/proc/self/cgroup").
This commit is contained in:
Cecile terpin 2019-12-11 14:27:23 +01:00 committed by GitHub
parent 307e56714e
commit ce0d09f04a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -66,12 +66,15 @@ public class ContainerInfo {
}
public static boolean isRunningInContainer() {
return Files.isReadable(CGROUP_DEFAULT_PROCFILE)
&& CGROUP_DEFAULT_PROCFILE.toFile().length() > 0;
return Files.isReadable(CGROUP_DEFAULT_PROCFILE);
}
public static ContainerInfo fromDefaultProcFile() throws IOException, ParseException {
final String content = new String(Files.readAllBytes(CGROUP_DEFAULT_PROCFILE));
if (content.isEmpty()) {
log.error("proc file is empty");
throw new IOException();
}
return parse(content);
}