[英]Python docker sdk how to set cpu count in containers.run
I am using docker SDK for python 3 and running a container using我正在为 python 3 使用 docker SDK 并使用运行容器
containers.run
We would like to set the number of CPU cores the container is getting and looked here我们想设置容器正在获取的 CPU 核心数并查看这里
There we saw there is a way to set the number of cores only under windows在那里我们看到有一种方法可以仅在 windows 下设置内核数
How can you do it in Ubuntu via that sdk in Python?您如何通过 Python 中的 sdk 在 Ubuntu 中做到这一点?
If not at all, How can i control the container getting 1 core, 2 cores etc.?如果根本没有,我如何控制容器获得 1 个核心、2 个核心等?
you may use cpuset_cpus
你可以使用
cpuset_cpus
cpuset_cpus (str) – CPUs in which to allow execution (0-3, 0,1).
cpuset_cpus (str) – 允许执行的 CPU (0-3, 0,1)。
so it looks like:所以它看起来像:
client.containers.run('alpine', cpuset_cpus="1")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.