简体   繁体   English

Python docker sdk 如何在containers.run中设置cpu计数

[英]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.

相关问题 python docker sdk 如何在containers.run 中运行多个命令 - python docker sdk how to run multiple commands in containers.run 运行Docker容器的Python脚本 - Python script to run docker containers 如何在Python SDK中运行docker命令 - How to run docker command in Python SDK 如何运行 docker 撰写使用 docker python sdk - how to run docker compose using docker python sdk 如何使用特定 GPU 运行 docker 容器 Docker SDK for Python - How to run a docker container with specific GPUs using Docker SDK for Python Python Docker:在 python docker 中以编程方式获取容器内存使用情况、CPU 百分比 - Python Docker: Get Containers memory usage, CPU percentage programmatically in python docker 使用 docker python SDk 创建多个容器失败 - Failed to create multiple containers using docker python SDk 如何使用带有 VS Code 的活动容器在 Docker 上运行 python 程序? - How Can I Run the python programs on Docker using active containers with the VS Code? 如何在后台运行 Python Docker 容器并在我的命令中使用它们? - How do I run Python Docker containers in the background and use them in my commands? 如何使用先前确定的 ip 地址和 python docker sdk 运行 docker 容器? - How to run a docker container with a previously determined ip address with the python docker sdk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM