How its is different installing mongodb in linux server and as docker in same linux server

I installed #MongoDB 4.2 in my linux 2c, 4 ram, 60 ssd machine with 7.2 gig size data

It cosumed all resources. I had to restart service everytime it failed

I deployed same size data in that same machine using docker container . It uses only 10% cpu, 1.5 gig ram