How to allocate 50% CPU resource to docker container via `docker run`?

后端 未结 5 1935
感情败类
感情败类 2020-12-13 19:10

I have a 4-core CPU, I want to allocate 50% CPU resource to a docker container.
After reading the docker-run manual and config.go source code.
I still don\'t know ho

5条回答
  •  醉酒成梦
    2020-12-13 19:49

    Since Docker 1.13, in your 4-core machine just add docker container run --cpus 2.0 [args...].

    Explanation from this blog post:

    In 1.13 though, if you want a container to be limited to one cpu then you can just add --cpus 1.0 to your Docker run/create command line. If you would like two and a half cpus as the limit of the container then just add --cpus 2.5. In Docker we are using the CFS quota and period to limit the container’s cpu usage to what you want and doing the calculations for you.

    Also check the docs.

提交回复
热议问题