简体   繁体   中英

How to limit the docker container memory usage

I have a vm flexible to change CPU and Memory on it. 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. Limiting the size of each container is the only option??

You can limit a container's resources (memory and CPU ) at run-time . For example :

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

to allow only 50% of a CPU for my-container .

Those settings are run-time settings , so you cannot set them in your Dockerfile .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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