Docker Container CPU and RAM Utilization
In this post will talk about resource allocation to docker containers.
Default behavior of docker container has no capacity limit. Its entitled to use the host available resources.
root@masterk8s:~# lscpu | grep -i "CPU(s)"
CPU(s): 2
On-line CPU(s) list: 0,1
NUMA node0 CPU(s): 0,1
root@masterk8s:~#
The host has 2 CPU's. I am going to create a container using the image progrium/stress.
This is the CPU/Memory stress image simulator.
root@masterk8s:~# docker run -d --rm progrium/stress -c 8 -t 20s
Above command creates a CPU spike on the container for 20 secs.
Since we have not set any limit on the container, It keeps using the host CPU.
It has reached the maximum of 197% of CPU ( As the host has 2 CPU's its ~ 200%)
Lets create a container to use 1 CPU.
Now, You can see the docker container is bound to 1 CPU (Max 100%).
Same pattern with Memory.
Comments
Post a Comment