Browse Source

Run update.sh

Docker Library Bot 8 years ago
parent
commit
dde2e3ffbb
3 changed files with 22 additions and 2 deletions
  1. 1 1
      hello-world/README.md
  2. 1 1
      hello-world/content.md
  3. 20 0
      openjdk/README.md

+ 1 - 1
hello-world/README.md

@@ -72,7 +72,7 @@ For more examples and ideas, visit:
 
 $ docker images hello-world
 REPOSITORY   TAG     IMAGE ID      SIZE
-hello-world  latest  1815c82652c0  1.84kB
+hello-world  latest  1815c82652c0  1.84 kB
 ```
 
 ![logo](https://raw.githubusercontent.com/docker-library/docs/01c12653951b2fe592c1f93a13b4e289ada0e3a1/hello-world/logo.png)

+ 1 - 1
hello-world/content.md

@@ -26,7 +26,7 @@ For more examples and ideas, visit:
 
 $ docker images hello-world
 REPOSITORY   TAG     IMAGE ID      SIZE
-hello-world  latest  1815c82652c0  1.84kB
+hello-world  latest  1815c82652c0  1.84 kB
 ```
 
 %%LOGO%%

+ 20 - 0
openjdk/README.md

@@ -107,6 +107,26 @@ $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp openjdk:7 javac Mai
 
 This will add your current directory as a volume to the container, set the working directory to the volume, and run the command `javac Main.java` which will tell Java to compile the code in `Main.java` and output the Java class file to `Main.class`.
 
+## Make JVM respect CPU and RAM limits
+
+On startup JVM tries to detect the number of available CPU cores and the amount of RAM to adjust its internal parameters (like the number of garbage collector threads to spawn) accordingly. When container is run with limited CPU/RAM, standard system API, used by JVM for probing, will return host-wide values. This can cause excessive CPU usage and memory allocation errors with older versions of JVM.
+
+Inside Linux containers, recent versions of OpenJDK 8 can correctly detect container-limited number of CPU cores by default. To enable the detection of container-limited amount of RAM the following options can be used:
+
+```console
+$ java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap ...
+```
+
+Inside Windows Server (non-Hyper-V) containers, limit for number of available CPU cores does not work (is ignored by Host Compute Service). To set such limit manually, JVM can be started the following way:
+
+```console
+$ start /b /wait /affinity 0x3 path/to/java.exe ...
+```
+
+In this example CPU affinity hex mask `0x3` will limit JVM to 2 CPU cores.
+
+RAM limit is supported by Windows Server containers, but currently JVM cannot detect it. To prevent excessive memory allocations, `-XX:MaxRAM=...` option must be specified with the value that is not bigger than a containers RAM limit.
+
 # Image Variants
 
 The `openjdk` images come in many flavors, each designed for a specific use case.