What is the difference between containers and virtual machines?
Both forms allow multiple operating systems to run on a single physical machine.
With containers, these operating systems are isolated (they have their own file systems, processes, libraries including the libc
, IP address, etc.) but they are nevertheless sharing the very same kernel. That's the reason why uname -a
showed your host kernel version.
With traditional virtualization, the operating systems have each one their own kernel running. These multiple kernels are not running on top of the real hardware, but on top of a virtualized hardware provided by a piece of software called an hypervisor. This is an extra layer compared to container based virtualization.
Each kind of virtualization has its strenghts and weaknesses. Containers are more limited in the choice of operating systems, the container one must be supported by the running kernel (e.g.: Solaris zones on Solaris, LXC on Linux, WPAR on AIX) although technically, nothing forbid kernel developers to implement the support for "alien" userlands (e.g.: lxbrand = Linux zones on Solaris 10 and SmartOS, or more recently Ubuntu runtime on Windows 10) while with hypervisors, the operating system needs only to be supported by the virtual hardware, which allows much heterogeneous configurations (e.g. : Linux 32 bit and 64 bit kernels, *BSDs, Solaris, Windows, Mac OS X, ...)
The major advantage of containers is they are much lighter, the application performance is essentially the same as what it would be with a true bare metal OS installation. New container instantiation is much faster because there is no extra kernel to boot, and the virtual environment density can be much higher because there are no extra kernels to run.
Note that Docker is not a container implementation. Docker is a building/packaging/distribution standard for applications running in containers and include an engine to run them and recently added an orchestrator too. This engine plays a role similar to the one of an hypervisor, but for applications on containers.