What is a Container?
In this lightboard talk, Ben Corrie explains what a container is for beginners.
A container is a lightweight, stand-alone, executable package that includes everything needed to run the software, including the code, a runtime, libraries, environment variables, and config files. Containers are designed to be portable and consistent across different development and deployment environments. Here are some key characteristics and benefits of containers:
Portability | Containers encapsulate an application and its dependencies, which makes it possible to run the application consistently across various computing environments. Whether it’s a developer’s laptop, a test server, or a cloud production environment, the application will run the same way. |
Lightweight | Containers are lightweight because they don’t need the extra load of a hypervisor but run directly within the host machine’s kernel. This means you can run more containers on a host machine than if you were using virtual machines. |
Isolation | Containers isolate the application processes from each other and the host system. This isolation allows you to run multiple containers on a single host machine, all sharing the host operating system but not interfering with each other. |
Scalability and Immutability: | Containers support agile and DevOps efforts, enabling developers to build and deploy applications faster and more securely. Because they are lightweight and start quickly, containers can be easily scaled up or down as needed. |
Efficiency | Containers are lightweight because they don’t need the extra load of a hypervisor but run directly within the host machine’s kernel. This means you can run more containers on a host machine than if you were using virtual machines. |
Microservices | Containers are often used in a microservices architecture. Each microservice runs in its container, allowing each service to be deployed, scaled, and managed independently. |
Version Control and Component Reuse | Containers support versioning; you can use them to build and roll back to a previous version if needed. They also encourage component reuse across different projects. |
Popular containerization platforms include Docker, Kubernetes (a container orchestrator), Podman, and others.
Comparison with Virtual Machines:
To understand containers better, comparing them with virtual machines (VMs) is helpful. A VM is an abstraction of physical hardware, turning one server into many servers. It includes a full copy of an operating system, one or more apps, necessary binaries, and libraries – taking up tens of GBs. VMs can also be slow to boot. In contrast, a container packages just the application and its dependencies. The container uses the host OS, and its size is in MBs, which means you can get more containers onto a host than if you were using VMs, and those containers can start almost instantly.
In summary, containers are a solution to the problem of how to get the software to run reliably when moved from one computing environment to another. They are one of the most impactful IT operations and DevOps developments in recent years.