Windows上的docker build命令期间的CPU资源

时间:2018-12-16 14:16:28

标签: docker docker-windows docker-build

如何控制Windows上的docker build命令使用多少个逻辑处理器?

我有这个dockerfile:

FROM mcr.microsoft.com/windows/servercore:1803
SHELL ["powershell", "-NoLogo"]
RUN Get-ComputerInfo -Property *proc*
CMD Get-ComputerInfo -Property *proc*

当我构建图像时,我看到以下输出:

CsNumberOfLogicalProcessors : 2
CsNumberOfProcessors        : 1

请注意,我的计算机具有4个逻辑处理器,当我使用--cpus 4选项运行容器时,会得到预期的结果:

CsNumberOfLogicalProcessors : 4
CsNumberOfProcessors        : 1

让我困惑的是,为什么docker build不支持--cpus选项,因为它在创建图像层时运行容器。

Docker信息:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 41
Server Version: 18.09.0
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: ics l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 17763 (17763.1.amd64fre.rs5_release.180914-1434)
Operating System: Windows 10 Pro Version 1809 (OS Build 17763.194)
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 7.891GiB
Name: Robo
ID: K3BP:UY7Z:JEXA:EJZ6:IYK6:WMW4:L4P4:5GTY:VR7K:SQKR:5QMO:AIEA
Docker Root Dir: C:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 28
 System Time: 2018-12-16T16:48:59.7060639Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

1 个答案:

答案 0 :(得分:1)

当前不支持。您可以在这里https://github.com/moby/moby/issues/38387

跟踪问题