6.1. Container Basics
problem. Endless debates arose about the merits and demerits of this situation,
which usually went something like this: “This is just another form of evil vendor
lock-in!” A great deal of thought was given to finding ways to address this evilness.
Meanwhile, others realized that the Linux kernel had some nice features that
could be used to bound and contain the resource utilization of process es: in
particular, control groups and name space isolation. These features allow for the
layering of new private virtual file system components on top of the host file system
and a specia l partitioned process space for applications to run usi ng libraries
virtually stored in the layered file system. For all practical purposes, a program
running in a container looks like it is running in its own V M, but without the
extra baggage of a complete OS. A contained application uses the resources of the
host OS, which can even control the amount of resource devoted to each container:
for example, the CPU percentage and the amount of memory and disk space.
By mid-2013, a l ittle company called dotCloud released a tool that provided
a better way to deploy encapsulated applications. This tool became Docker [
71
],
and dotCloud became Docker, Inc.
docker.com
. Microsoft also figured out how to
do the same thing with Windows. While other container technologies exist, we
focus primarily on Docker in this book.
Docker allows applications to be provisioned in containers that encapsulate all
application dependencies. The application sees a complete, priva te process space,
file system, and network interface isolated from applications in other containers on
the same host operating system. Docker isolation provides a way to factor large
applications, as well as simple ways for running containers to communicate with
each other. When Docker is installed on Linux, Windows 10, or Mac, it runs on
a base Linux kernel called Alpine that is u sed for every container instance. As
we describe below, additional OS features are layered on top of that base. This
layering is the key to container portabili ty across clouds.
Docker is designed to support a variety of distributed applications. It is now
widely used in the Internet industry, including by major companies like Yelp,
Spotify, Baidu, Yandex, and eBay. Importantly, Docker is supported by major
public cloud providers, including Google, Microsoft, Amazon, and IBM.
To understand how containers are built and used, one must understand how the
file system in a container is layered on top of the existin g host services. The key is
the
Union File System
(more p recisel y, the advanced multilayered unification
file system (AuFS) and a special property called copy on write that allows the
system to reuse many data objects in multiple containers.
86