What are Containers as they relate to DevOps?
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
Containers and virtual machines (VM) have similar resource isolation and allocation benefits. However, they function differently because containers virtualize the operating system (OS) instead of hardware. This makes containers much more portable and efficient.
Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs, can handle more applications and require fewer VMs and operating systems. This is possible because container images are typically tens of MBs in size, making them much smaller than VMs.
Software teams using containers and orchestration tend to reap the following benefits:
- Platform independence: Build it once, run it anywhere
- A major benefit of containers is their portability. A container wraps up an application with everything it needs to run, like configuration files and dependencies. This enables you to easily and reliably run applications on different environments such as your local desktop, physical servers, virtual servers, testing, staging, production environments and public or private clouds. This portability grants organizations a great amount of flexibility, speeds up the development process, and makes it easier to switch to another cloud environment or provider.
- Resource efficiency and density
- Since containers do not require a separate operating system, they use up less resources. While a VM often measures several gigabytes in size, a container usually measures only a few dozen megabytes, making it possible to run many more containers than VMs on a single server.
- Effective isolation and resource sharing
- Although containers run on the same server and use the same resources, they do not interact with each other. If one application crashes, other containers with the same application will keep running flawlessly and won’t experience any technical problems. This isolation also decreases security risks: If one application should be hacked or breached by malware, any resulting negative effects won’t spread to the other running containers.
- Speed: Start, create, replicate or destroy containers in seconds
- Containers are lightweight and start in less than a second since they do not require an operating system boot. Creating, replicating or destroying containers is also just a matter of seconds, thus greatly speeding up the development process, the time to market and the operational speed. The increased speed also offers great opportunities for improving customer experience, since it enables organisations and developers to act quickly, for example when it comes to fixing bugs or adding new features.
- Immense and smooth scaling
- A major benefit of containers is that they offer the possibility of horizontal scaling, meaning you can add more identical containers within a cluster to scale out. With smart scaling, where you only run the containers needed in real time, you can reduce your resource costs drastically and accelerate your return on investment. Container technology and horizontal scaling has been used by major vendors like Google, Twitter and Netflix for years now.
- Operational simplicity
- Containers execute application processes in isolation from the underlying host OS. This means that your host OS doesn’t need specific software to run applications, which makes it simpler to manage your host system and quickly apply updates and security patches.
- Improved developer productivity and development pipeline
- A container-based infrastructure offers many advantages, promoting an effective development pipeline. As mentioned before, containers ensure that applications run and work as designed locally. This elimination of environmental inconsistencies makes testing and debugging less complicated and less time-consuming since there are fewer differences between running your application on your workstation, test server or in any production environment.