skip to Main Content

I am on working on Windows Server 2019 and trying to run a docker container of CentOS on it. I am running the following:

PS C:Windowssystem32> docker run -dit --name=testing23 --cpu-shares=12    raycentos:1.0
6a3ffb86c1d9509a9d80f0de54fc6acf5731ca645ee74e6aabe41d7153b3af70
PS C:Windowssystem32> docker exec -it 6a3ffb86c1d9509a9d80f0de54fc6acf5731ca645ee74e6aabe41d7153b3af70 bash
(app-root) bash-4.2# nproc
2

It still specifies only 2, and not 32. How can we assign more CPUs to the container?

2

Answers


  1. refer to this topic for more details https://docs.docker.com/config/containers/resource_constraints/#cpu

    you have to add the values with proper flags

    try :

        --cpus=<value> for maximum CPU resources a container can use
        --cpuset-cpus = 12
    
    Login or Signup to reply.
  2. By default, all can be used, or you can limit it per container using the --cpuset-cpus parameter.

    docker run --cpuset-cpus="0-2" myapplication:latest
    

    That would restrict the container to 3 CPU’s (0, 1, and 2). See the docker run docs for more details.

    The chosen way to limit CPU usage of containers is with a fractional limit on CPUs:

    docker run --cpus 2.5 myapplication:latest
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search