是否可以在运行时获取docker容器的最大内存?
我想要实现的目标是:
public function downloadAttachment()
{
$id = JRequest::getInt('id');
$user = JFactory::getUser();
$model = $this->getModel('Attachment');
$item = $model->getAttachment($id);
if(!$user->guest)
{
echo "<p><strong>Check if you are allowed to download...</strong></p>";
if($user->get('isRoot'))
{
echo "<p><strong>Preparing...</strong></p>";
$filename = $item->filename; //Name to display
$filepath = $item->filepath;
// start download now...
}
}
else
{
echo "<p><strong>You are not allowed to download this file...</strong></p>";
}
}
并访问docker文件中的最大内存:
docker run --memory "100m"
答案 0 :(得分:5)
不要认为你可以在Dockerfile中指定内存约束。所以这样做的方法是在命令行覆盖entrypoint
:
$ docker run -i -t --memory "100m" --entrypoint "java -Xmx`cat /sys/fs/cgroup/memory/memory.limit_in_bytes` -jar helloworld.jar" example/java-hello