March 09, 2017

Docker Installation Architecture

Docker Installation Architecture

You can install Docker Engine on top of Linux, Mac and Windows operating systems.
This figure shows a native Linux OS Docker deployment. This is a Linux system with several Docker applications installed. The Docker daemon manages the Docker containers:

This example shows that Docker can be deployed as an application on older Windows or Mac systems via the Docker Toolbox. Toolbox uses docker-machine to provision a VirtualBox VM, which runs the boot2docker Linux distribution, and manages containers via the Docker daemon:

This next example shows the Docker daemon installed directly on a supported Mac or Windows OS, creating containers on top of a HyperKit VM (Mac) or Hyper-V VM (Windows):

Docker provides an efficient mechanism to build, ship, and run any app on any OS on any platform, i.e. physical host, virtual host or in the cloud:

Docker creates lightweight and self-contained run-time environments, making it seamless for developers to move projects from the development stage to production.

It's possible to run Containers inside a Virtual Machine. The above figure shows a Docker engine/daemon with two containers, running in one of the three VMs on a Virtualization host.

Container and Virtual Machine Differences

Container and Virtual Machine Differences

The differences between a Docker Container and a hypervisor-based Virtual Machine can be highlighted as follows:
  • Footprint
    • Each VM on the host runs its own (guest) operating system
    • Containers share a single kernel, that of the hosts' operating system
    • Advantage… to the container as sharing the kernel allows for more efficient operations, e.g. a reduction in the amount of maintenance needed, as only one OS needs to be patched and maintained in a container environment. Containers hold only the application and the dependencies it needs to run so disk footprint is tiny
  • Processes
    • Each VM hosts an operating system, with a full complement of native applications and processes
    • A container runs a single application. Any other processes are children of the default application
    • Advantage… to the container. A single-application system provides agility and a more efficient operation
  • Setup
    • Setting up a VM requires some amount of system administration knowledge
    • A container is a user-space process and requires little to no system administrator intervention
    • Advantage… to the container. It is a more developer-friendly environment in terms of setup
  • Portability
    • A VM can be setup as a standalone environment with the full execution environment needed by its main applications
    • The container is a single-application environment. For multi-tier applications, multiple containers are typically needed
    • Both environments can be migrated to different hosts or from a testing to a production environment, the advantage however is to the container as it provides higher level abstraction such that there is little or no additional configuration needed (e.g. networking, file system) post migration. Also the containers' "migration bundle" is smaller and easier to manage.
"Containers are to Virtual Machines as threads are to processes."

If virtualization is a force-multiplier for system administrators, containerization is a force-multiplier for developers.

Container and Virtual Machine Similarities

Containers and virtual machines (VMs) are complementary. VMs excel at providing extreme isolation (for example in multi-tenant environments). Containers operate at the process level, as such, they are lightweight and an efficient mechanism for software delivery. A VM may take minutes to boot, containers start in seconds or less.

Containers package an application with all of its dependencies and it will run the same in any environment.
Virtual machines package an operating system with all its dependencies and allow it to run the same independent of the hardware platform.

Similarities between container and VM:
  • lightweight VM
  • shell access
  • Feature:
    • own process space
    • own network interface
    • root access
    • install and update services
Differences between container and VM:
  • uses the host kernel
  • cannot boot a different OS
  • cannot have its own modules
  • By default, runs a single application
  • doesn't need additional system processes, e.g. init, syslogd, cron
  • Runs as a process on the host machine

Containers on a host share the kernel of the host operating system, then leveraging kernel parameters such as cgroups and namespaces, each container has its own, isolated CPU, memory, block I/O, and network resources. "The result is something that feels like a virtual machine, but sheds all the weight and startup overhead of a guest operating system."

Advantages of Hypervisor-based Virtual Machines
Run multiple different operating systems on a single host.
Secure as communication between guest and host is directed through the hypervisor
Abstracts the full hardware environment (enabling access even to older hardware)
Advantages of Containers
Consumes less system resources: memory, space, CPU
Increased scalability fitting more containers on a host
Developer-friendly, including needed application environment in an efficient package