Docker run -m没有设置限制(JVM占用了xms和xmx的整个主机大小) [英] Docker run -m doesnt set the limit (JVM takes up the entire host machine's size for xms and xmx)

查看:982
本文介绍了Docker run -m没有设置限制(JVM占用了xms和xmx的整个主机大小)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台具有16GB RAM的服务器.我正在尝试通过运行

I have a server with 16GB RAM. I am trying to set the memory limit to the container by running

docker run -it -m 500M <image-name>

在docker stats上,它显示该容器的内存限制为500MB.但是当我尝试做

On the docker stats, it shows the container has the memory limit of 500MB. But when i try to do

docker exec -it <containerID> /bin/sh

并做一个顶部",它将可用内存显示为16GB.

and do a "top", it shows the available memory as 16GB..

是否应将其设置为500MB?

Should it not be set to 500MB ?

为什么我需要500 MB的主要原因是我在每个容器中都运行了Java应用程序.默认情况下,JVM将16gb/64作为Xms,将4gb作为Xmx. :(

The main reason why i need it to be 500 MB is I have java application running in each container. And by default the JVM takes 16gb/64 as the Xms and 4gb as Xmx. :(

推荐答案

我认为本文将帮助您理解为什么free和top在容器内无法正常工作.

I think this article will help you to understand why free and top doesn't work correctly inside containers.

Most of the Linux tools providing system resource metrics were created before 
cgroups even existed (e.g.: free and top, both from procps). They usually read 
memory metrics from the proc filesystem: /proc/meminfo, /proc/vmstat, 
/proc/PID/smaps and others.

Unfortunately /proc/meminfo, /proc/vmstat and friends are not containerized. 
Meaning that they are not cgroup-aware. They will always display memory 
numbers from the host system (physical or virtual machine) as a whole, which 
is useless for modern Linux containers

This causes a lot of confusion for users of Linux containers. Why does free 
say there is 32GB free memory, when the container only allows 512MB to be 
used?

https://fabiokung.com/2014/03/13/memory-inside-linux-containers/

这篇关于Docker run -m没有设置限制(JVM占用了xms和xmx的整个主机大小)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆