4
CHAPTER 1 | Introduction to Containers and Docker
Virtual Machines
Docker Containers
Virtual machines
include the application, the
required libraries or binaries, and a full guest
operating system. Full
virtualization requires
more resources than containerization.
Containers include the application and all its
dependencies. However, they share the OS kernel
with
other containers, running as isolated
processes in user space on the host operating
system. (Except in Hyper-V containers, where
each container runs inside of a special virtual
machine per container.)
Figure 2-3. Comparison of traditional virtual machines to Docker containers
For VMs, there are three base layers
in the host server, from the bottom-up: infrastructure, Host
Operating System and a Hypervisor and on top of all that each VM has its own OS and all necessary
libraries. For Docker, the host server only has the infrastructure and
the OS and on top of that, the
container engine, that keeps container isolated but sharing the base OS services.
Because containers require far fewer resources (for example, they don’t need a full OS), they’re easy
to
deploy and they start fast. This allows you to have higher density, meaning that it allows you to run
more services
on the same hardware unit, thereby reducing costs.
As a side effect of running on the same kernel, you get less isolation than VMs.
The main goal of an image is that it makes the environment (dependencies) the same across different
deployments. This means that you can debug it on your machine and
then deploy it to another
machine with the same environment guaranteed.
A container image is a way to package an app or service and deploy it in a reliable and reproducible
way. You could say that Docker isn’t only a technology but also a philosophy and a process.
When using Docker, you won’t hear developers say, “It works on my machine, why not in production?”
They
can simply say, “It runs on Docker”, because the packaged Docker application can be executed
on any supported Docker environment, and it runs the way it was intended to on all deployment
targets (such as Dev, QA, staging, and production).
Dostları ilə paylaş: