[Avg. reading time: 9 minutes]
Introduction
World before containers
Physical Machines
- 1 Physical Server
- 1 Host Machine (say some Linux)
- 3 Applications installed
Limitation:
- Need of physical server.
- Version dependency (Host and related apps).
- Patches ”hopefully” not affecting applications.
- All apps should work with the same Host OS.
- Long startup times.
- Complex backup and disaster recovery processes.
- 3 physical server
- 3 Host Machine (diff OS)
- 3 Applications installed
Limitation:
- Each application is isolated on its own physical server.
- Different OS can be used for each application.
- No dependency conflicts between applications.
- Higher hardware costs (3 physical servers).
- Resource utilization is typically low.
- Maintenance requires managing multiple different OS environments.
- Complex networking between applications.
- Higher operational costs.
Virtual Machines
-
Virtual Machines emulate a real computer by virtualizing it to execute applications,running on top of a real computer.
-
To emulate a real computer, virtual machines use a Hypervisor to create a virtual computer.
-
On top of the Hypervisor, we have a Guest OS that is a Virtualized Operating System where we can run isolated applications, called Guest Operating System.
-
Applications that run in Virtual Machines have access to Binaries and Libraries on top of the operating system.
( + ) Full Isolation, Full virtualization
( - ) Too many layers, Heavy-duty servers.
Key Benefits of this Architecture:
- Better resource utilization than separate physical servers
- Strong isolation between applications
- Ability to run different OS environments
- Easier backup and snapshot capabilities
- Better than single OS but still has overhead
- Each VM requires its own OS resources
- Slower startup times compared to containers
- Higher memory usage due to multiple OS instances
Here comes Containers
Containers are lightweight, portable environments that package an application with everything it needs to run—like code, runtime, libraries, and system tools—ensuring consistency across different environments. They run on the same operating system kernel and isolate applications from each other, which improves security and makes deployments easier.
-
Containers are isolated processes that share resources with their host and, unlike VMs, don’t virtualize the hardware and don’t need a Guest OS.
-
Containers share resources with other Containers in the same host.
-
This gives more performance than VMs (no separate guest OS).
-
Container Engine in place of Hypervisor.
Key Benefits of Container Architecture:
- Lightweight compared to VMs (no guest OS)
- Fast startup times
- Consistent environment across development and production
- Better resource utilization
- Portable across different platforms
- Isolated dependencies prevent conflicts
- Easy scaling and updates
- Standardized deployment process