The Missing Introduction to Containerization
Long answer:
When Docker started it used LXC as a container runtime, the idea was to create an API to manage the container runtime, isolate single processes running applications and supervise the container life cycle and the resources it uses. Docker, Libcontainer and Linux Kernel FacilitiesLet’s Create a Container Using Namespaces  Cgroups
I am using Ubuntu in this example, but it should be the same for most distros. If we do the same thing on the host machine (no imitation on a 16G RAM), the test will never fail, unless you really do not have enough free memory:
Following these steps will help in understanding how Linux facilities like CGroups and other resource control features can create and manage isolated environments in Linux systems.
Source: medium.com