当我这样做时 docker info
它给了我以下结果:
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 2
Total Memory: 7.632 GiB
但我希望 cpu 为 1 而不是 2。如何限制 docker 本身的 CPU?
最佳答案
在 Windows 上,打开 powershell 并键入
# turn off all wsl instances such as docker-desktop
wsl --shutdown
notepad "$env:USERPROFILE/.wslconfig"
编辑 .wslconfig
用记事本创建文件并记下这些设置:[wsl2]
memory=3GB # Limits VM memory in WSL 2 up to 3GB
processors=2 # Makes the WSL 2 VM use two virtual processors
类型 wsl
在 PowerShell 中重新启动 docker
类型
docker info
你应该看到类似的东西Architecture: x86_64
CPUs: 2
Total Memory: 6.789GiB
感谢 Ali Bahraminezhad,查看他的帖子 here
关于docker - 限制 docker 守护进程 CPU 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46598762/