Docker engine combines the namespaces, control groups and UnionFS into a wrapper called a container format. The default container format is libcontainer.
Each of containers A and B has its own naespaces. OS kernel limits the resources(CPU memory. etc.) to A and B according to cgroups on A and B
VM = virtualization on HW level
Container = virtualization on OS level
Cgroups and namespaces are features implemented to realize "original container" in mid 2000s as Linux project.
Namespaces = a set of names of objects managed by kernel such as process IDs, user IDs, file names, names associated network access, etc.
In a (virtual)host, OS manages all processes, i.e, monolithic namespaces because there is only one space of processes and system resources, files, physical memory and so on.
In containers, each set of containers needs to be isolated from each other.Thus separate namespaces for each set of containers.
Cgroups are a Linux kernel feature that limits and isolates the resource usage of a collection of processes.
In order to share OS kernel, all the containers must be built on 'same' OS kernel meaning that systen calls are consistent. Docker Engine is responsible to administrate different kernel versions to make sure that all the system calls each container invokes are compatible with the OS kernel shared by containers.
Docker makes use of kernel namespaces to provide the isolated workspace called the container.
When you run a container, docker creates a set of namespaces for that container.
These namespaces provide a layer of isolation.
Docker also makes use of kernel control groups for resource allocation and isolation. A cgroup limits an application to a specific set of resources.
Control groups allow Docker Engine to share available hardware resources to containers and optionally enforce limits and constarints.
Docker Engine combines the namespaces, control groups and UnionFS into a wrapper called a container format. The default container format is libcontainer.
출처
홍익대학교 Software Engineering by prof.김한규