<div dir="ltr"><div class="gmail_default" style="font-size:small"><font face="arial, sans-serif">Hi,<br><br>I am trying the ContainerSupport feature.<br><a href="https://bugs.openjdk.org/browse/JDK-8196595">https://bugs.openjdk.org/browse/JDK-8196595</a><br><br>This is my sample code<br>```<br>package com.example;<br><br>import com.sun.management.OperatingSystemMXBean;<br>import java.lang.management.ManagementFactory;<br>import java.util.concurrent.TimeUnit;<br><br>public class App {<br>  public static void main(String[] args) {<br>    OperatingSystemMXBean bean =<br>        (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();<br>    while (true) {<br>      System.out.println("processors: " + bean.getAvailableProcessors());<br>      System.out.println("memory: " + bean.getTotalPhysicalMemorySize());<br>      try {<br>        TimeUnit.SECONDS.sleep(5);<br>      } catch (Exception e) {<br>      }<br>    }<br>  }<br>}<br>```<br><br>I compiled this sample code with OpenJDK 8 without JVM argument `-XX:+UseContainerSupport`,<br>and I dockerize it based on openjdk:8u342<br>```<br>FROM openjdk:8u342<br>COPY ./app/build/install/app /app<br>CMD [ "/app/bin/app" ]<br>```<br><br>Then, I ran this built image on Linux Docker Engine with the following command<br>```<br>docker run --rm -it --cpus 1 -m 1G {image} <br>```<br><br>I got the output as I expected.<br>```<br>processors: 1<br>memory: 1073741824<br>```<br><br>However, when I tried to run the same built image on macOS Docker Engine (Intel Chip) with the same image and command,<br>the output was my macOS Docker Engine's host information<br>```<br>processors: 4<br>memory: 6233055232<br>```<br>(My macOS Docker Engine has set resources limit to 4CPU and 6GB Memory)<br><br><br>I checked the cgroup files in the container. For example, <br>```<br># cat /sys/fs/cgroup/memory.max<br>1073741824<br>```<br><br>It seems that macOS Docker Engine did set cgroup properly.<br><br>I also tried building the same application based on openjdk:17-alpine (without re-compiling the code with JDK 17, only changing the base image)<br>```<br>FROM openjdk:17-alpine<br>COPY ./app/build/install/app /app<br>CMD [ "/app/bin/app" ]<br>```<br><br>and I tested the image with the same command on macOS.</font></div><div class="gmail_default" style="font-size:small"><font face="arial, sans-serif">It displayed the expected result.<br>```<br>> docker run --rm -it --cpus 1 -m 1G {image}<br>processors: 1<br>memory: 1073741824<br>```<br><br>I wonder if someone encounters the same case?<br><br>Thank you!</font><br></div></div>