A container packages an application with the dependencies, libraries, and configuration files it needs to run. Containers on the same host share its operating system kernel but remain logically isolated from one another. This makes an application easier to move between environments while keeping its behavior consistent. section 13.4.2
A virtual machine runs its own operating system. A container does not, so it generally starts faster and uses fewer resources. An organization can run more application instances on one host or move an application from a developer’s laptop to a data center or cloud platform. section 13.4.2
|
|
Virtual
Machines (VMs)
|
Containers
|
|
Virtualization
|
Full
(Hypervisor emulates entire hardware stack)
|
Lightweight
(Container engine shares the host OS)
|
|
Isolation
|
Strong
(each VM instance has its own OS)
|
Moderate
(each container is a runtime environment on the same shared OS)
|
|
Startup Time
|
Slow
(minutes)
|
Fast
(seconds)
|
|
Performance
|
~15% loss
|
<2% loss
|
|
Density
|
10–100
instances per host
|
100–1000
instance per host
|
|
Security Risks
|
Compromise
of OS is typically contained to that VM
|
Shared OS
increases potential blast radius on OS security attacks
|
|
Ideal Use Case
|
Running
multiple fully independent OS environments
|
Rapid
deployment of microservices and applications
|
|
Virtualization
|
Full
(Hypervisor emulates entire hardware stack)
|
Lightweight
(Container engine shares the host OS)
|
|
Isolation
|
Strong
(each VM instance has its own OS)
|
Moderate
(each container is a runtime environment on the same shared OS)
|
Compare containers and virtual machines by isolation, startup time, resource use, density, security risk, and typical use. section 13.4.2
Sharing the host kernel is a trade-off: container isolation is weaker than the isolation between virtual machines with separate operating systems. An attack on the shared operating system can therefore affect more containers. Containers suit rapid application deployment, including microservices, when their efficiency and portability justify that trade-off. section 13.4.2
Moving an application
A team can package an application and its dependencies as a container, then run it on a developer’s laptop, in a corporate data center, or on a cloud platform. Docker provides a way to build, ship, and run containers. section 13.4.2































