【发布时间】:2020-01-07 07:29:58
【问题描述】:
我正在尝试让 Docker 使用我硬件上所有可用的 CPU 内核 (4)。 Docker 只能看到一个 CPU 核心:
$ docker run --cpuset-cpus="0-3" -ti ubuntu bash
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Requested CPUs are not available - requested 0-3, available: 0.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
如何让 Docker 使用所有可用的内核?
Docker 文档声称将 cpus 标志设置为 0.000 会强制 Docker 使用所有可用的内核,但这对我不起作用:
$ docker run --cpus=0.000 -ti ubuntu bash
root@36855ab28928:/# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
stepping : 9
microcode : 0x19
cpu MHz : 2890.620
cache size : 4096 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 cx16 pcid sse4_1 sse4_2 popcnt aes xsave avx rdrand hypervisor lahf_lm pti fsgsbase
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips : 5781.24
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
$ docker run --cpus=0.000 -ti ubuntu bash
root@6c1d6934a0fe:/# lscpu | head -n 10
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
root@6c1d6934a0fe:/#
我正在使用 Docker 快速启动终端来获取您在上面看到的命令提示符。
我的物理硬件是一台 Windows 10 笔记本电脑。在 Windows 上的 Ubuntu 上使用 Bash:
$ lscpu | head -n 10
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
我安装了 Oracle VM Virtualbox,但我不知道这是否与此有关。我是一个 Docker 新手。 Stack Overflow (1) 上的其他答案声称默认情况下所有 CPU 都是可用的,并且没有在网上找到相反的信息。我搜索了 Docker 文档,没有发现任何表明我需要做一些特别的事情来解锁其他 CPU 内核。
【问题讨论】:
标签: docker