Windows container

Limit windows container resources

In this blog, we will show you how to limit windows container resources like CPU, memory using docker commands.

OVERVIEW

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.

DOCKER HELP

  • If we run docker run – -help command there are few flags which help us to configure CPU usage.
Limit windows container resources
  • 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.
Limit windows container resources
  • 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

Limit windows container resources
  • Earlier the CPU status is
Limit windows container resources
  • CPU status after container creation.
Limit windows container resources
  • 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.

VIDEO

Thanks for reading this blog. We hope it was useful for your to learn how to control CPU and memory for windows container.

Loges