Get memory limit in docker file?

2019-06-24 15:01发布

Is it possible to get the max memory of a docker container at runtime?

What I want to achieve is:

docker run --memory "100m"

and access the max memory in the docker file:

ENTRYPOINT ["java", "-Xmx$memory", "-jar", "helloworld.jar"]

标签: java docker
1条回答
手持菜刀,她持情操
2楼-- · 2019-06-24 15:33

Don't think you can specify memory constraints in the Dockerfile yet. So the way to do it is to override your entrypoint at the command line:

$ docker run -i -t --memory "100m" --entrypoint "java -Xmx`cat /sys/fs/cgroup/memory/memory.limit_in_bytes` -jar helloworld.jar" example/java-hello
查看更多
登录 后发表回答