JDK-8261242 : [Linux] OSContainer::is_containerized() returns true when run outside a container
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2021-02-05
  • Updated: 2024-07-08
  • Resolved: 2024-07-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b05Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Currently the code in Hotspot in order to determine whether or not the JVM thinks it runs in a container may return false positives on a plain Linux host.

This can be observed for example by running jshell with container trace logging (it shows many traces since -XX:+UseDynamicNumberOfCompilerThreads is on by default, which queries for available memory going through the container detection code):
$ jshell -J-Xlog:os+container=trace

Bob mentions that there wasn't a reliable way to detect whether or not a JVM runs in a container:

https://bugs.openjdk.java.net/browse/JDK-8227006?focusedCommentId=14275609&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14275609

I believe this changed. We should be able to determine whether we run in a container by looking at the controller mounts inside a container. Container engines typically mount them read-only, while on a host system they are read write. This is useful to detect the "inside a container case". Note that the mount options are field 6 as per 'man procfs' under /proc/pid/mountinfo.

Host system case (note the 'rw' mount options):
$ grep cgroup /proc/self/mountinfo 
53 51 0:27 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:7 - tmpfs tmpfs ro,seclabel,size=4096k,nr_inodes=1024,mode=755,inode64
54 53 0:28 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:8 - cgroup2 cgroup2 rw,seclabel,nsdelegate
55 53 0:29 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:9 - cgroup cgroup rw,seclabel,xattr,name=systemd
56 53 0:33 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,seclabel,blkio
57 53 0:34 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,seclabel,net_cls,net_prio
58 53 0:35 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:12 - cgroup cgroup rw,seclabel,cpu,cpuacct
59 53 0:36 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,seclabel,pids
60 53 0:37 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,seclabel,memory
61 53 0:38 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,seclabel,rdma
62 53 0:39 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,seclabel,freezer
63 53 0:40 / /sys/fs/cgroup/misc rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,seclabel,misc
64 53 0:41 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,seclabel,perf_event
65 53 0:42 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,seclabel,hugetlb
66 53 0:43 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,seclabel,cpuset
67 53 0:44 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,seclabel,devices

Container case (note the 'ro' mount options):
# grep cgroup /proc/self/mountinfo
1531 1508 0:119 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs cgroup rw,context="system_u:object_r:container_file_t:s0:c405,c449",size=1024k,uid=15263,gid=15263,inode64
1532 1531 0:44 /user.slice /sys/fs/cgroup/devices ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,devices
1533 1531 0:43 / /sys/fs/cgroup/cpuset ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,cpuset
1534 1531 0:42 / /sys/fs/cgroup/hugetlb ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,hugetlb
1535 1531 0:41 / /sys/fs/cgroup/perf_event ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,perf_event
1536 1531 0:40 / /sys/fs/cgroup/misc ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,misc
1537 1531 0:39 / /sys/fs/cgroup/freezer ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,freezer
1538 1531 0:38 / /sys/fs/cgroup/rdma ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,rdma
1539 1531 0:37 /user.slice/user-15263.slice/user@15263.service /sys/fs/cgroup/memory ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,memory
1540 1531 0:36 /user.slice/user-15263.slice/user@15263.service /sys/fs/cgroup/pids ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,pids
1541 1531 0:35 /user.slice/user-15263.slice/user@15263.service /sys/fs/cgroup/cpu,cpuacct ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,cpu,cpuacct
1542 1531 0:34 / /sys/fs/cgroup/net_cls,net_prio ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,net_cls,net_prio
1543 1531 0:33 /user.slice/user-15263.slice/user@15263.service /sys/fs/cgroup/blkio ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,blkio
1544 1531 0:29 /user.slice/user-15263.slice/user@15263.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-0f301a31-cd1d-4b62-b798-9810bc79990b.scope /sys/fs/cgroup/systemd ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,seclabel,xattr,name=systemd

Yet, looking at rw/ro mount options isn't enough. Features like JDK-8217338 have been added to use the container detection code to figure out memory/cpu limits enforced by other means. We'd be introducing a regression when we only looked at the read/write property of controller mounts. Therefore, we need a fall-back to look at the container limits at OSContainer::init time. If there are any, we could set OSContainer::is_containerized() to true for that reason.

Using the fall-back approach only is insufficient since it's expected (asserted in container tests), for the when OpenJDK runs inside a container, (without a limit) to return is_containerized() = true.
Comments
[~mbaesken] Thanks. I've filed JDK-8335882 to track this.
08-07-2024

Hi Severin, we now fail (probably related to the change) on our Linux Alpine test machine. Output is stdout: []; stderr: [Operating System Metrics: No metrics available for this platform openjdk version "24-internal" 2024-07-05 OpenJDK Runtime Environment (fastdebug build 24-internal-adhoc.jenkinsi.jdk) OpenJDK 64-Bit Server VM (fastdebug build 24-internal-adhoc.jenkinsi.jdk, mixed mode, sharing) ] exitValue = 0 java.lang.RuntimeException: 'System not containerized.' missing from stdout/stderr at jdk.test.lib.process.OutputAnalyzer.shouldContain(OutputAnalyzer.java:252) at TestSystemSettings.main(TestSystemSettings.java:43) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138) at java.base/java.lang.Thread.run(Thread.java:1575)
05-07-2024

Changeset: 0a6ffa57 Author: Severin Gehwolf <sgehwolf@openjdk.org> Date: 2024-07-01 08:47:29 +0000 URL: https://git.openjdk.org/jdk/commit/0a6ffa57954ddf4f92205205a5a1bada813d127a
01-07-2024

After this patch OSContainer::is_containerized() will return true/false in the following scenarios: "OSContainer::is_containerized() value" => "Actual deployment scenario" ----------------------------------------------------------------------------------------------- true => OpenJDK runs in an unprivileged container without a cpu/memory limit true => OpenJDK runs in an unprivileged container with a cpu/memory limit true => OpenJDK runs in a privileged container with a cpu/memory limit false => OpenJDK runs in a privileged container without a cpu/memory limit false => OpenJDK runs in a systemd slice without a cpu/memory limit true => OpenJDK runs in a systemd slice with a cpu/memory limit false =>OpenJDK runs on a physical Linux system (VM or bare metal)
28-06-2024

PlainRead test should change with this issue.
13-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18201 Date: 2024-03-11 16:55:36 +0000
11-03-2024

Basic testing also indicates this works with crio: $ sudo crictl exec -it 62ec8c448da7f /bin/bash [root@b3aa86768b25 /]# /opt/jdk/bin/java -Xlog:os+container=trace --version [0.000s][trace][os,container] OSContainer::init: Initializing Container Support [0.000s][debug][os,container] Detected optional pids controller entry in /proc/cgroups [0.000s][debug][os,container] Detected cgroups hybrid or legacy hierarchy, using cgroups v1 controllers [0.000s][trace][os,container] Path to /memory.use_hierarchy is /sys/fs/cgroup/memory/memory.use_hierarchy [0.001s][trace][os,container] Use Hierarchy is: 1 [0.001s][debug][os,container] OSContainer::init: is_containerized() = true because all controllers are mounted read-only (container case)
11-03-2024

Let's try to implement this for JDK 23.
11-03-2024

I also propose to expose this state with the -XshowSettings:system output, like so (on not containerized system): ./build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XshowSettings:system --version Operating System Metrics: Provider: cgroupv1 System not containerized. openjdk 23-internal 2024-09-17 OpenJDK Runtime Environment (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk) OpenJDK 64-Bit Server VM (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing)
08-03-2024

Results using a prototype implementation (on a Linux host system - not containerized): $ ./build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xlog:os+container=trace --version [0.000s][trace][os,container] OSContainer::init: Initializing Container Support [0.000s][debug][os,container] Detected optional pids controller entry in /proc/cgroups [0.000s][debug][os,container] Detected cgroups hybrid or legacy hierarchy, using cgroups v1 controllers [0.001s][trace][os,container] Path to /memory.use_hierarchy is /sys/fs/cgroup/memory/user.slice/user-15263.slice/user@15263.service/memory.use_hierarchy [0.001s][trace][os,container] Use Hierarchy is: 1 [0.001s][trace][os,container] total physical memory: 67167305728 [0.001s][trace][os,container] Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/user.slice/user-15263.slice/user@15263.service/memory.limit_in_bytes [0.001s][trace][os,container] Memory Limit is: 9223372036854771712 [0.001s][trace][os,container] Non-Hierarchical Memory Limit is: Unlimited [0.001s][trace][os,container] Path to /memory.stat is /sys/fs/cgroup/memory/user.slice/user-15263.slice/user@15263.service/memory.stat [0.001s][trace][os,container] Hierarchical Memory Limit is: 9223372036854771712 [0.001s][trace][os,container] Hierarchical Memory Limit is: Unlimited [0.001s][debug][os,container] container memory limit unlimited: -1, using host value 67167305728 [0.001s][trace][os,container] Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu,cpuacct/user.slice/user-15263.slice/user@15263.service/cpu.cfs_quota_us [0.001s][trace][os,container] CPU Quota is: -1 [0.001s][trace][os,container] Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu,cpuacct/user.slice/user-15263.slice/user@15263.service/cpu.cfs_period_us [0.001s][trace][os,container] CPU Period is: 100000 [0.001s][trace][os,container] OSContainer::active_processor_count: 12 [0.001s][debug][os,container] OSContainer::init: is_containerized() = false because no cpu or memory limit is present openjdk 23-internal 2024-09-17 OpenJDK Runtime Environment (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk) OpenJDK 64-Bit Server VM (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing) When running in a container: $ podman run --rm -ti -v $(pwd)/build/linux-x86_64-server-fastdebug/images/jdk:/opt/jdk:z fedora:39 /opt/jdk/bin/java -Xlog:os+container=trace --version [0.000s][trace][os,container] OSContainer::init: Initializing Container Support [0.000s][debug][os,container] Detected optional pids controller entry in /proc/cgroups [0.001s][debug][os,container] Detected cgroups hybrid or legacy hierarchy, using cgroups v1 controllers [0.001s][trace][os,container] Path to /memory.use_hierarchy is /sys/fs/cgroup/memory/memory.use_hierarchy [0.001s][trace][os,container] Use Hierarchy is: 1 [0.001s][debug][os,container] OSContainer::init: is_containerized() = true because all controllers are mounted read-only (container case) [0.001s][trace][os,container] Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us [0.001s][trace][os,container] CPU Quota is: -1 [0.001s][trace][os,container] Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us [0.001s][trace][os,container] CPU Period is: 100000 [0.001s][trace][os,container] OSContainer::active_processor_count: 12 [0.001s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 12 [0.001s][trace][os,container] total physical memory: 67167305728 [0.001s][trace][os,container] Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/memory.limit_in_bytes [0.001s][trace][os,container] Memory Limit is: 9223372036854771712 [0.001s][trace][os,container] Non-Hierarchical Memory Limit is: Unlimited [0.001s][trace][os,container] Path to /memory.stat is /sys/fs/cgroup/memory/memory.stat [0.001s][trace][os,container] Hierarchical Memory Limit is: 9223372036854771712 [0.001s][trace][os,container] Hierarchical Memory Limit is: Unlimited [0.001s][debug][os,container] container memory limit unlimited: -1, using host value 67167305728 [0.002s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 12 [0.056s][trace][os,container] Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us [0.056s][trace][os,container] CPU Quota is: -1 [0.056s][trace][os,container] Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us [0.056s][trace][os,container] CPU Period is: 100000 [0.056s][trace][os,container] OSContainer::active_processor_count: 12 [0.062s][trace][os,container] total physical memory: 67167305728 [0.062s][trace][os,container] Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/memory.limit_in_bytes [0.062s][trace][os,container] Memory Limit is: 9223372036854771712 [0.062s][trace][os,container] Non-Hierarchical Memory Limit is: Unlimited [0.062s][trace][os,container] Path to /memory.stat is /sys/fs/cgroup/memory/memory.stat [0.062s][trace][os,container] Hierarchical Memory Limit is: 9223372036854771712 [0.062s][trace][os,container] Hierarchical Memory Limit is: Unlimited [0.062s][debug][os,container] container memory limit unlimited: -1, using host value 67167305728 openjdk 23-internal 2024-09-17 OpenJDK Runtime Environment (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk) OpenJDK 64-Bit Server VM (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing) Systemd slice: $ sudo systemctl daemon-reload && sudo systemctl restart user-cg-cpu.slice && sudo systemd-run --slice user-cg-cpu.slice --scope ./build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xlog:os+container=trace --version Running scope as unit: run-r21aef3c6b23545478974aa8ee480e6ac.scope [0.000s][trace][os,container] OSContainer::init: Initializing Container Support [0.000s][debug][os,container] Detected optional pids controller entry in /proc/cgroups [0.000s][debug][os,container] Detected cgroups hybrid or legacy hierarchy, using cgroups v1 controllers [0.000s][trace][os,container] Path to /memory.use_hierarchy is /sys/fs/cgroup/memory/user.slice/user-cg.slice/user-cg-cpu.slice/run-r21aef3c6b23545478974aa8ee480e6ac.scope/memory.use_hierarchy [0.001s][trace][os,container] Use Hierarchy is: 1 [0.001s][trace][os,container] total physical memory: 67167305728 [0.001s][trace][os,container] Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/user.slice/user-cg.slice/user-cg-cpu.slice/run-r21aef3c6b23545478974aa8ee480e6ac.scope/memory.limit_in_bytes [0.001s][trace][os,container] Memory Limit is: 9223372036854771712 [0.001s][trace][os,container] Non-Hierarchical Memory Limit is: Unlimited [0.001s][trace][os,container] Path to /memory.stat is /sys/fs/cgroup/memory/user.slice/user-cg.slice/user-cg-cpu.slice/run-r21aef3c6b23545478974aa8ee480e6ac.scope/memory.stat [0.001s][trace][os,container] Hierarchical Memory Limit is: 104857600 [0.001s][debug][os,container] OSContainer::init: is_containerized() = true because either a cpu or a memory limit is present [0.001s][trace][os,container] Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu,cpuacct/user.slice/user-cg.slice/user-cg-cpu.slice/cpu.cfs_quota_us [0.001s][trace][os,container] CPU Quota is: 200000 [0.001s][trace][os,container] Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu,cpuacct/user.slice/user-cg.slice/user-cg-cpu.slice/cpu.cfs_period_us [0.001s][trace][os,container] CPU Period is: 100000 [0.001s][trace][os,container] CPU Quota count based on quota/period: 2 [0.001s][trace][os,container] OSContainer::active_processor_count: 2 [0.001s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 2 [0.002s][trace][os,container] CgroupSubsystem::active_processor_count (cached): 2 [0.044s][trace][os,container] Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu,cpuacct/user.slice/user-cg.slice/user-cg-cpu.slice/cpu.cfs_quota_us [0.044s][trace][os,container] CPU Quota is: 200000 [0.044s][trace][os,container] Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu,cpuacct/user.slice/user-cg.slice/user-cg-cpu.slice/cpu.cfs_period_us [0.044s][trace][os,container] CPU Period is: 100000 [0.044s][trace][os,container] CPU Quota count based on quota/period: 2 [0.044s][trace][os,container] OSContainer::active_processor_count: 2 [0.052s][trace][os,container] total physical memory: 67167305728 [0.052s][trace][os,container] Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/user.slice/user-cg.slice/user-cg-cpu.slice/run-r21aef3c6b23545478974aa8ee480e6ac.scope/memory.limit_in_bytes [0.052s][trace][os,container] Memory Limit is: 9223372036854771712 [0.052s][trace][os,container] Non-Hierarchical Memory Limit is: Unlimited [0.052s][trace][os,container] Path to /memory.stat is /sys/fs/cgroup/memory/user.slice/user-cg.slice/user-cg-cpu.slice/run-r21aef3c6b23545478974aa8ee480e6ac.scope/memory.stat [0.052s][trace][os,container] Hierarchical Memory Limit is: 104857600 [0.052s][trace][os,container] Path to /memory.usage_in_bytes is /sys/fs/cgroup/memory/user.slice/user-cg.slice/user-cg-cpu.slice/run-r21aef3c6b23545478974aa8ee480e6ac.scope/memory.usage_in_bytes [0.052s][trace][os,container] Memory Usage is: 35520512 [0.054s][trace][os,container] Path to /memory.usage_in_bytes is /sys/fs/cgroup/memory/user.slice/user-cg.slice/user-cg-cpu.slice/run-r21aef3c6b23545478974aa8ee480e6ac.scope/memory.usage_in_bytes openjdk 23-internal 2024-09-17 [0.054s][trace][os,container] Memory Usage is: 36306944 OpenJDK Runtime Environment (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk) OpenJDK 64-Bit Server VM (fastdebug build 23-internal-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing)
08-03-2024

One property that I've been working with the past couple of days is that whether or not cgroup controllers are mounted read-only. This at least lets us detect host (Linux) systems and containers apart. Host systems have them rw, (unprivileged) containers ro.
25-08-2023

[Edit: 2023-08-25] Sorry, Ioi, misread your comment. So as to whether we should interpret cgroup settings set by docker or some other means differently? No, we should not. Is the OSContainer::is_containerized() API useful? Yes. It should tell us whether or not we run in a "container" of some form (with a limit in place: memory or cpu). If we have determined that we are indeed running in such an isolating container, we could do something useful with it. For example adjusting MaxRAMPercentage or the like. Why? Because the common container use-case is run a container on the cloud with a memory/cpu limit and expect that container to run a single process (the JVM with the app).
25-08-2023

I wonder about the usefulness of the oscontainer::is_containerized() API. If the user uses cgroups directly (without using a “container” like docker), should we interpret the cgroup memory limits differently than if the limits are set by docker?
10-08-2023

I've been discussing whether or not there is some OCI spec'ed file that could be looked at to discover containerization. Apparently there isn't and there is no plan to add this. So my current thinking is that we might want to expand semantics of is_containerized() to only return true if any limit is in place (cpu or memory), not just merely looking at the cgroup controllers' presence.
09-08-2023

After some further research using those environment files for specific runtime systems doesn't work, because you don't have any guarantees which runtime system is in place. In terms of Kubernetes it might be cri-o, runc, crun, containerd etc. Any OCI compliant runtime. For example for containerd or cri-o based containers those files don't exist. Similarly for kata containers. One example using cri-o: $ cat container-config.json pod-config.json { "metadata": { "name": "busybox" }, "image":{ "image": "docker.io/busybox" }, "command": [ "top" ], "log_path":"busybox.0.log", "linux": { } } { "metadata": { "name": "busybox", "namespace": "default" }, "image":{ "image": "docker.io/busybox" }, "command": [ "top" ], "log_path":"busybox.0.log", "linux": { } } $ sudo crictl run container-config.json pod-config.json 538a0343f0778d274fb5488e6cd4c94e60adfe3612f3c38853aedcfab2da2e98 $ sudo crictl exec -i -t 538a0343f0778d274fb5488e6cd4c94e60adfe3612f3c38853aedcfab2da2e98 /bin/sh / # ls /.dockerenv ls: /.dockerenv: No such file or directory / # ls /run/.containerenv ls: /run/.containerenv: No such file or directory So any departure from using the cgroups pseudo filesystem and checking existence of (needed) controllers would be a regression.
29-03-2022

Proof of Concept patch. The idea would be to add a -XX:IsContainerized flag to get the old behaviour back. Immediately deprecated. Removed with JDK 20/21. Yes, this would need a CSR: https://github.com/openjdk/jdk/compare/cb576da575ea3c8f14087dd312313843764ca2f4...jerboaa:is_containerized_poc_8261242
23-03-2022

[~iklam] Are you working on this? Otherwise, I can take a look at this.
21-03-2022