简体   繁体   English

如何限制Docker容器的内存使用量

[英]How to limit the docker container memory usage

I have a vm flexible to change CPU and Memory on it. 我有一个可以更改其上的CPU和内存的vm flexible。 I have 5 containers running on it.The 3 three slave containers execute test cases.But when I run the containers,I see that the entire CPU is being filled.Even I increase the size of CPU ,it is also being filled.How do I overcome it. 我有5个容器在运行。三个3个从属容器执行测试用例。但是,当我运行这些容器时,我看到整个CPU都已装满。即使我增加了CPU的大小,也装满了它。我克服了。 Limiting the size of each container is the only option?? 限制每个容器的大小是唯一的选择??

You can limit a container's resources (memory and CPU ) at run-time . 您可以在运行时 限制容器的资源 (内存和CPU )。 For example : 例如 :

docker run --cpus=".5" my-container

to allow only 50% of a CPU for my-container . 只允许50%的CPU用于my-container

Those settings are run-time settings , so you cannot set them in your Dockerfile . 这些设置是运行时设置 ,因此无法在Dockerfile设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM