• Home
  • Docker Resource Limits

Docker Resource Limits

22 May 2019 Bajrang Gupta Comments Off
One of the big features of docker is the ability to enforce limits on how many resources a container is gonna use. 
You can limit it to a fixed amount of memory, and it prevents the container from clobbering the rest of the system.
$ docker run –memory command
You can equally limit the CPU time, you can limit relative, you can say give this container half of the total CPU time and the other one the other half so that if one’s not busy the other can use more CPU. But, then it will enforce that they have equal access. 
$ docker run –cpu-shares (relative to other containers)
You can also give them hard limits. Say, this container only gets to use 10 percent of the CPU total ever, even if 90 percent of the CPU time is idle. 
$ docker run –cpu-quota (limit the CPU usage)