- April 12, 2017
- Posted by: Loges
- Category: Blog, Containers
Limit windows container resources
In this blog, we will show you how to limit windows container resources like CPU, memory using docker commands.
We will set CPU and memory usage while creating VM. Likewise, we can also have resource control for windows containers. We can configure it using docker commands. It’s a function of docker run command.
- If we run docker run – -help command there are few flags which help us to configure CPU usage.
- The common flag which we use for windows container is – -cpu-percent int. It allows you to specify the percentage of container host CPU resources that should be used.
- In addition to this, there are few flags to specify the memory usage.
- The common flag which to specify memory is – –memory string
- We need to specify the CPU and memory usage while creating the containers. The reason is if a process requires a huge amount of memory if we don’t specify these settings while creating the container, it will utilize all the memory in the container host machine.
SETTING CPU AND MEMORY USAGE
- To set the CPU and memory usage while creating containers, use the below option.
docker run -it –memory 1g –cpu-percent 20 microsoft/nanoserver
- Earlier the CPU status is
- CPU status after container creation.
- There is not much vary in the CPU & memory performance. So it’s not pre-provisioning the resources to the containers. We are allowing the container to use up to 1GB of memory and 20% of CPU.
Thanks for reading this blog. We hope it was useful for your to learn how to control CPU and memory for windows container.