Docker containers have their own kernel or not?

Solution 1:

Docker uses host OS kernel, there is no custom or additional kernel inside container. All containers which run on a machine are sharing this "host" kernel.

Wikipedia says http://en.wikipedia.org/wiki/Docker_(software) that

Docker uses resource isolation features of the Linux kernel such as cgroups and kernel namespaces to allow independent "containers" to run within a single Linux instance, avoiding the overhead of starting virtual machines.

cgroups, namespaces and LXC are features of Linux kernel to isolate groups of processes; there is still single kernel, single scheduler, and one instance of kernel memory manager.

Boot2docker and CoreOS are just lightweight Linux distributions with some host kernel; they can be used to load Docker containers.

http://boot2docker.io/

boot2docker is a lightweight Linux distribution based on Tiny Core Linux made specifically to run Docker containers. It runs completely from RAM, weighs ~27MB and boots in ~5s (YMMV).

http://en.wikipedia.org/wiki/CoreOS

A single control host (CoreOS instance) runs multiple isolated Linux systems (containers), using Docker as an additional layer of abstraction and interface[14] to the underlying operating-system-level virtualization features of the Linux kernel. ... This approach relies on the Linux kernel's cgroups functionality, which provides namespace isolation and abilities to limit, account and isolate resource usage (CPU, memory, disk I/O, etc.) for the collections of processes.

Solution 2:

In almost all cases, the host OS kernel is shared. To run a different kernel you need to use virtualization. This is rare and only used when necessary due to performance degradation.

"The Docker Engine container comprises just the application and its dependencies. It runs as an isolated process in userspace on the host operating system, sharing the kernel with other containers. Thus, it enjoys the resource isolation and allocation benefits of VMs but is much more portable and efficient."

This might help explain how it works: enter image description here

Source: https://www.docker.com/whatisdocker/

Solution 3:

All the docker containers use the host kernel.

It would also mean, that some incompatibility between a host kernel and the container distro could cause problems. In theory. For example, if a containerized software would want to use some kernel feature what was not compiled into the host kernel, then it would not work.

The practice is that this does not happen. The main trouble source of the docker containers are the (often unexplainable) limitations of the docker itself, and not some host-guest kernel incompatibility.

(P.s. It is because practically all Linux distros work with any Linux kernel.)