Docker uses way more memory than python program on its own

I have created a program in python that simulates business processes. For extremely large processes, the simulation can run for hours and the memory requirements are in GB. However, if I create a docker container, the docker image consumes cca 3x more memory than the original python program and if I limit the memory of the docker to even 2x the original python memory, the python program inside the docker will fail with out of memory error.

Taggings:

1 answer

This one is the BEST answer!

it seems that the reason why Docker uses much more memory is that it does not allow the operating system to use virtual memory (swap memory). What I didn't see in the original debugging, is that the python program consumes memory of several GB, but windows has automatically moved another several GB of memory to virtual memory to save RAM space. This is however not enabled in docker environment, so the only RAM available to the docker is the one that is specified in the set up phase.