An Introduction to Containers
Welcome to this first look at containers, the technology that has taken the software engineering world by storm over the last 15 years.
What is a container
Containers are a way to package software so that it is portable, (more) secure, and isolated from other units of software on the host it resides. Unlike VMs, which virtualize the entire OS, kernel, and resources (disk, RAM, CPU), containers share the underlying host's kernel and only use the resources they're allotted when necessary. This allows for far greater density and, due to the way they are packaged, portability—but more on that in a moment.
Container Characteristics
There are 4 main characteristics that make containers so powerful:
1. Isolation
Containers encapsulate an application and its dependencies. This provides a clean environment that is separate from other processes on the host.
2. Portability
Because containers package all that they need to run, they can be easily moved between different hosts. Something really exciting here is that those hosts can be nodes in the cloud, on-prem servers, or even your dev laptop.
3. Efficiency
Containers share the host system's operating system kernel, which significantly reduces overhead compared to virtual machines (VMs) that each require their own virtualized kernel. This efficiency is a key factor in why containers allow for higher density.
4. Scalability
Containers can be easily scaled horizontally across multiple nodes or by adding more instances on the same node. Their lightweight design enables quick startup times, making them well-suited for dynamic, microservices-based architectures.
Why Containers Matter
If you've ever heard a fellow developer say, "it works on my machine," you're probably painfully aware of the main problem containers are designed to address. By packaging software in containers, along with all its necessary dependencies, you can be confident that your containerized application will run consistently across different environments, with only minor variations due to differences in CPU architectures.
Containers also play a critical role in modern DevOps practices by enabling continuous integration and continuous deployment (CI/CD). With containers, developers can automate all of the build, test, and deployment functionality for their applications, increasing team velocity.
Dive deeper on the benefits of containerization.
Containers vs Virtual Machines
Let's take a look at the most relevant differences between containers and VMs:
Resource Virtualization and Usage - Virtual machines require the virtualization of not only the kernel but also CPU, RAM, and disk space. These "allotments" are given to each virtual machine by the hypervisor at start time and cannot be accessed by other VMs on the host. Containers are given limits as to how much they can use of these resources, and they only use what they need at any given time.
Startup Time - Due to the nature of VMs described above, there is much more that needs to happen on start/init. Containers start almost instantly.
Portability - Containers are designed to be portable. VMs are generally tied to a specific infrastructure.
Get started with containers by taking the next step and learning how to build a container image with Docker.