docker internal
if you look in the Linux kernel, there is no such thing as a container
- Containers share the host kernel
- Containers use the kernel ability to group processes for resource control
- Containers ensure isolation through namespaces
Containers feel like lightweight VMs (lower footprint, faster)
history
- Chroot circa 1982
- FreeBSD Jails circa 2000
- Solaris Zones circa 2004
- Meiosys - MetaClusters with Checkpoint/Restore 2004-05
- Linux OpenVZ circa 2005 (not in mainstream Linux)
- AIX WPARs circa 2007
- LXC circa 2008
- Systemd-nspawn circa 2010-2013
Docker circa 2013
-- built on LXC
-- moved to libcontainer (March 2014)
-- appC (CoreOS) announced (December 2014)
-- Open Containers standard for convergence with Docker Announced (June 2015)
-- moved to runC (OCF compliant) (July 2015)how it works
Namespaces, cgroups, Images, Layers & copy-on-write
Kernel Namespaces: isolation
- Process trees (PID Namespace)
- Mounts (MNT namespace) wc -l /proc/mounts
- Network (Net namespace) ip addr
- Users / UIDs (User Namespace)
- Hostnames (UTS Namespace) hostname
Inter Process Communication (IPC Namespace) ipcs
Control Group: accounting
Kernel control groups (cgroups) allow you to do accounting on resources used by processes, a little bit of access control on device nodes and other things such as freezing groups of processes.
IPTables (networking)
solation on the networking level is achieved through the creation of virtual switches in the linux kernel. Linux Bridge is a kernel module, first introduced in 2.2 kernel (circa 2000). And it is administered using the brctl command on Linux.
Types of Containers
Given the above constructs, containers may be divided into 3 types as follows:
- System Containers share rootfs, PID, network, IPC and UTS with host system but live inside a cgroup.
- Application Containers live inside a cgroup and use namespaces (PID, network, IPC, chroot) for isolation from host system
- Pods use namespaces for isolation from host system but create sub groups which share PID, network, IPC and UTS except the rootfs.
docker providing
- Image management
- Resource Isolation
- File System Isolation
- Network Isolation
- Change Management
- Sharing
- Process Management
- Service Discovery (DNS since 1.10)
refer: