在Docker容器中运行时,JVM无法映射保留的内存

Kay*_*lly 11 java jvm mmap docker

我似乎无法在我的服务器上的Docker容器中运行java.即使发布java -version,我也会收到以下错误.

root@86088d679103:/# java -version
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000035ce1000000, 2555904, 1) failed; error='Operation not permitted' (errno=1)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2555904 bytes for committing reserved memory.
# An error report file with more information is saved as:
# //hs_err_pid17.log
Run Code Online (Sandbox Code Playgroud)

据此,java无法为预留内存映射2.5Mb的空间?这似乎不对......

我在最后包含了完整的日志,但为了获得一些额外的信息,我的系统报告了以下内容:

root@86088d679103:/# uname -m
x86_64
root@86088d679103:/# free -mh
             total       used       free     shared    buffers     cached
Mem:           15G       9.7G       5.8G       912K       148M       8.9G
-/+ buffers/cache:       639M        14G
Swap:          15G         0B        15G
Run Code Online (Sandbox Code Playgroud)

谁能指出我正确的方向?

完整日志:https://gist.github.com/KayoticSully/e206c44681ce261674ba

更新

@Yobert解决了这个问题,我强烈建议你仔细阅读评论和聊天记录.好消息在那里.

对于那些想要使Java工作的最终命令的人: setfattr -n user.pax.flags -v "mr" /usr/bin/java

如果您的发行版setfattr默认没有安装,它应该通过paceman,apt-get等包含在可安装包中.

Yob*_*ert 12

使用支持Grsec的内核时,我遇到了同样的问题.为了让java玩得很好,我不得不在java二进制文件上禁用MPROTECT.您可以使用该paxctl实用程序:

paxctl -m /usr/lib/jvm/java-7-openjdk/jre/bin/java
Run Code Online (Sandbox Code Playgroud)

paxctl -c如果您之前从未在二进制文件上使用二进制文件,则需要先对二进制文件执行以下操作:

paxctl -c /usr/lib/jvm/java-7-openjdk/jre/bin/java
Run Code Online (Sandbox Code Playgroud)

有关paxctl的更多信息,请访问:http://en.wikibooks.org/wiki/Grsecurity/Additional_Utilities


小智 11

在Alpine Linux上运行Docker时遇到了同样的问题,在启用PaX软模式后它运行了:

sysctl -w kernel.pax.softmode=1
Run Code Online (Sandbox Code Playgroud)

默认情况下,软模式将禁用大多数PaX功能,因此不建议启用它.正确的方法是使用paxctl,如上所述.

另请看这里:https: //en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Support_soft_mode