Azure DevOps管道未设置docker内存
我已经成功地设置了一个自托管代理来从Azure DevOps构建管道。但是,现在我需要增加机器分配给docker容器的默认1GB内存 如果我运行docker并检查其内存:Azure DevOps管道未设置docker内存,docker,azure-devops,azure-pipelines,azure-pipelines-yaml,Docker,Azure Devops,Azure Pipelines,Azure Pipelines Yaml,我已经成功地设置了一个自托管代理来从Azure DevOps构建管道。但是,现在我需要增加机器分配给docker容器的默认1GB内存 如果我运行docker并检查其内存: docker run mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed 我明白了 这是
docker run mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
我明白了
这是默认的1GB内存空间(在Windows主机上运行)。如果我在docker run
中设置-m
选项:
docker container run -m 4294967296 mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
我明白了
这并不完全是我所期望的(我期望像第一行一样),但我可以接受它,因为我不需要确切的内存量,只需要超过1GB。由于在命令行上启动docker时,-m
选项对我来说很好,因此我将其作为一个选项添加到我的容器中(我还添加了--CPU
以检查选项是否生效):
我在yml文件上配置的管道由两个作业组成,一个具有默认docker容器设置,另一个具有-m
和-CPU
选项:
jobs:
- job: windowsbuild
displayName: "Windows build"
pool:
name: 'Default'
container:
image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
options: -m 4294967296 --cpus="8"
steps:
- script:
systeminfo
displayName: 'System information'
- script:
wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
displayName: 'Memory information'
- script:
wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
displayName: 'CPU information'
- script: |
mkdir build
cd build
cmake ..
cmake --build . --config RelWithDebInfo
RelWithDebInfo\hello_world.exe
displayName: 'Hello world compilation'
- job: secondjob
displayName: "Second job"
dependsOn: windowsbuild
pool:
name: 'Default'
container:
image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
steps:
- script:
systeminfo
displayName: 'System information'
- script:
wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
displayName: 'Memory information'
- script:
wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
displayName: 'CPU information'
令我惊讶的是,这两个作业为内存命令提供了相同的输出。此输出为1GB,忽略“windows build”作业的-m
标志:
然而,CPU命令确实生效了。在“Windows构建”作业中,我得到:
Caption DeviceID MaxClockSpeed Name NumberOfCores NumberOfEnabledCore NumberOfLogicalProcessors Status
Intel64 Family 6 Model 158 Stepping 10 CPU0 3192 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 4 8 8 OK
Caption DeviceID MaxClockSpeed Name NumberOfCores NumberOfEnabledCore NumberOfLogicalProcessors Status
Intel64 Family 6 Model 158 Stepping 10 CPU0 3192 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 1 2 2 OK
在“第二份工作”中,我得到了:
Caption DeviceID MaxClockSpeed Name NumberOfCores NumberOfEnabledCore NumberOfLogicalProcessors Status
Intel64 Family 6 Model 158 Stepping 10 CPU0 3192 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 4 8 8 OK
Caption DeviceID MaxClockSpeed Name NumberOfCores NumberOfEnabledCore NumberOfLogicalProcessors Status
Intel64 Family 6 Model 158 Stepping 10 CPU0 3192 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 1 2 2 OK
因此,每个环境都有适当数量的CPU
你知道我的内存部分出了什么问题吗?我已经更改了脚本,你可以尝试一下,然后在这里分享结果
trigger: none
jobs:
- job: windowsbuild
displayName: "Windows build"
pool:
name: 'Default'
container:
image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
steps:
- task: CmdLine@2
inputs:
script: |
systeminfo
wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
- job: secondjob
displayName: "Second job"
dependsOn: windowsbuild
pool:
name: 'Default'
container:
image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
options: -m 4294967296
steps:
- task: CmdLine@2
inputs:
script: |
systeminfo
wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
结果:
Hi@apalomer,我只是想看看这个问题现在是否还在阻碍你?此问题是否有更新?我不知道
选项:-m 4294967296
如何生效。在右侧屏幕截图中,您有4GB,是的。但是在左边的屏幕截图上也有4GB,并且管道的该部分不存在选项:-m 4294967296
。
Caption DeviceID MaxClockSpeed Name NumberOfCores NumberOfEnabledCore NumberOfLogicalProcessors Status
Intel64 Family 6 Model 158 Stepping 10 CPU0 3192 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 1 2 2 OK
trigger: none
jobs:
- job: windowsbuild
displayName: "Windows build"
pool:
name: 'Default'
container:
image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
steps:
- task: CmdLine@2
inputs:
script: |
systeminfo
wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
- job: secondjob
displayName: "Second job"
dependsOn: windowsbuild
pool:
name: 'Default'
container:
image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
options: -m 4294967296
steps:
- task: CmdLine@2
inputs:
script: |
systeminfo
wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status