I have a host with a resource of 8 cores / 16 GB RAM. We use cgroup
to allocate CPU
and memory
for our custom application. We tried to create a static partition resource between our custom application and docker. For example, we are trying to allocate the following :-
4 CPU cores / 8 GB RAM --> docker
3 CPU cores / 6 GB RAM --> custom_app_1
the remaining for OS
We have manage to perform the segregation for custom_app_1
. Question is how I create a default limit memory and cpu to our container without having to use the flag --memory
or --cpus
for individual container. I don't need to limit each container but I need to make sure that all containers running in the host cannot exceed the usage of 8GB RAM and 4 CPU cores, otherwise, it will be fighting resources with my custom_app_1
When i perform docker stats
, each container is seeing 16 GB RAM, how do I configure so that they only see 8 GB RAM and 4 CPU cores instead
So what you need to do is create a SystemD slice for the memory.
Then configure that slice in
/etc/docker/daemon.json
Reload systemctl and restart docker
See the relevant section in documentation
DEFAULT CGROUP PARENT