How to reduce default VM memory for Docker Linux containers on Windows

隐身守侯 提交于 2020-01-12 03:55:48

问题


Scenario

  • Windows 10 Professional
  • Docker 18.06.1-ce running in Windows container mode
  • 4GB of available memory on host system
  • using Hyper-V virtual machine

Problem

When trying to "switch to Linux containers" via Docker's taskbar item the process fails after a couple of seconds showing an error about "Not enough memory to start Docker".

Since the host system does not have that much memory, I'd like to reduce the maximum amount of memory the global Docker machine is allowed to use (I think 2 GB is the default here). Thus, I'd like to reduce that to just 1 GB.

When having Docker running in Windows container mode, there is no "advanced" section in Docker's settings that would allow to reduct that memory assignment easily.

I was able to find the "MobyLinuxVM" using Windows' Hyper-V manager. However, when adjusting memory settings there, it is overwritten each time I start Docker and try again switching to Linux container mode.

Question

Is there a different way to define the maximum amount of memory for Docker without using the user interface (which won't work in this scenario due to the missing "advanced" section in Windows container mode - before being able to switch to Linux containers)?


回答1:


After some searching I found out that settings of Docker's user interface are stored in %APPDATA%\Docker\settings.json, memory settings are defined in VmMemory property.

The following solved the problem on my environement:

  • quit Docker
  • modify settings.json file using notepad %APPDATA%\Docker\settings.json in the run command prompt (Windows-Key + R)
  • adjust value VmMemory to 1024 (has been 2048 before)
  • save settings.json
  • start Docker and finally being able to use "switch to Linux containers"



来源:https://stackoverflow.com/questions/52904104/how-to-reduce-default-vm-memory-for-docker-linux-containers-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!