Search code examples
dockermemorymemory-managementdocker-desktop

Why is my container is not using the available RAM of my host machine?


I'm running docker on a windows machine with 16GB RAM. My container uses 4GB of memory as per docker stats(see output below). However, there is no process as per my windows task manager taking that kind of memory, and the memory usage on my computer does not change when i start/stop my container.

Thus my questions are

  1. From where the 4GB of RAM used by container is coming from (disk as RAM?)
  2. How can i configure my container to use the available RAM

My container is extremely slow and I suspect its because of the above behavior; where it is using disk as virtual memory and thus not really using the resources(RAM) available to it.

$ docker stats

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
66a9ccfd0a51        quirky_wozniak      0.04%               4.268GiB / 4.815GiB   88.63%              113kB / 20.2kB      40.8MB / 1.07MB     16

task manager screen shot

Docker Settings


Solution

  • Docker for Windows typically runs a VM to support Linux containers. The memory given to this VM is the memory available on the docker host. In the preferences, there is a menu to configure the number of CPU cores and amount of memory to dedicate to this VM:

    Advance VM settings

    (Image credit: Docker for Windows documentation)