Introduction to Containers

Introduction to Containers

Mohammadjavad Raadi

Mohammadjavad Raadi

Containers provide a standard and powerful way of packaging, distributing, and deploying software applications and running them at a large scale. If you are building and deploying microservices, data processing jobs, machine learning applications, or if you are thinking of moving your existing application to the cloud, container technology is a great fit for you. In this introduction article, we will explain what a container is, how it compares with a virtual machine (VM), what operational and cost benefits it offers, and how an organization can successfully adopt this new technology.

What is a Container?

One of the most common challenges of software development and release teams is running their applications in different environments. This happens because the underlying operating system, libraries, and configurations the application relies on might be different from one machine (environment) to another. Container technology allows bundling up the application code, binaries and all its requirements so that it is portable and runs smoothly on any computing environment, be it your personal computer, your private data center or the public cloud. Another challenge is to maximize the resource utilization of the underlying hardware in the most efficient way. A container is lightweight, has less overhead, boots up fast, requires less computing power to operate, and can scale in and out rapidly.

For a while, Virtual Machines were the de facto way of operating applications. They provide similar features and benefits, but they are different. Let’s see how.

Containers vs. Virtual Machines

Both containers and Virtual Machines are designed to help us make use of physical resources (CPU, memory etc.) and computing power as much as possible. With the advancement of physical hardware and the flexibility of cloud computing, you can run multiple instances of multiple applications either as a Virtual Machine or a container and make sure that your underlying infrastructure is not underutilized.

VMs vs. Containers

In order to run a Virtual Machine, you will need to install hypervisor software on top of the operating system. The hypervisor software (host) emulates physical hardware and allows multiple isolated operating systems (guest OS) to be installed on top of it. This is what a VM is. Each VM thinks it’s running on bare metal hardware. You will then need to install your application and all its dependencies on top of it. Since each VM requires its own guest OS, the deployment package tends to be many gigabytes in size and requires significant computing power to run and operate.

In order to run a container, you will need to install Container Engine software on top of the operating system (host). The Container Engine emulates at the operating system level and allows you to create many containers. Each container runs as an isolated process and shares the resources with the underlying host kernel. Containers tend to be much lighter in size than Virtual Machines when distributed because they don’t need to pack a full operating system to run. They also require less computing power.

In terms of workload isolation and security concerns, Virtual Machines provide the ultimate security boundary. However, a properly secured, updated and patched virtualization environment provides security restrictions and process isolation that can be applied to workloads running in Virtual Machines or containers.

Operational and Cost Benefits of Containers

Containers have become very popular in the past few years because container technology improves the software development and deployment lifecycle significantly. It improves resource utilization, reduces costs and speeds up time-to-market. Let’s examine the benefits in detail:

  • Small in size: A normal Virtual Machine image and the machine based on that is likely to be gigabytes in size whereas a typical container image requires far less (think “megabytes”) of storage. For this, the underlying host requires less provisioned storage capacity and IO operations which results in reducing costs.
  • Modularity and Scalability: One of the struggles with any software application is modularity and breaking the components into smaller scalable pieces. With containers, you no longer need to host an entire application on a single piece of hardware or machine. You can break down the application into modules, domains or services and run them inside their own container individually. This way, containers can come and go and constantly scale in and out to meet the demand. For this to work, you will probably need to rearchitect your application and adopt microservice practices.
  • Instant start: Virtual Machines require booting up an entire OS and starting services, in order to be able to serve the application. On the other hand, containers start instantly and are ready to work within seconds. The same applies to stopping and destroying containers.
  • Better Developer Experience: Every developer has their own favorite development stack (machine, OS, IDE, …), but we need to make sure that their productions run exactly the same on any machine and operating system. A containerized application is guaranteed to work seamlessly in any environment. This will save developers the hassle of dealing with environment-specific issues and let them focus on delivering value.
  • Efficiency: Containers significantly reduce overhead and resource usage compared to other virtualization methods because they don’t require a dedicated operating system and hypervisor software to operate. When they are properly configured, they can consume all the available CPU and memory efficiently, allowing a single host to run many functions.
  • Easier Management and Orchestration: In order to run container workloads in production at a large scale, you need an application that can manage the load and operations. You should be able to easily rollout an update - or rollback if something goes wrong. You should be able to scale up to hundreds or thousands and scale back down to a minimum according to demand. You need a mechanism to find out when containers aren’t healthy and recover them. You need a container orchestration application. Fortunately, there’s Kubernetes. Kubernetes is an open source container orchestration service developed by Google, which has been widely adopted and tested in production.

How to Adopt Container Technology?

The pace of IT innovations is blazing fast and the adoption of the containerization is happening across the private data centers, public cloud providers and hybrid environments. Software developers were the ones who started experimenting and adopting the use of containers, and more and more IT professionals and organizations broadened the adoption to leverage the benefits of containerized applications and services.

As with every new technology, container adoption comes with a learning curve. Depending on your use case and the level of involvement, you will need to learn to use new tools like Docker, grasp new concepts, and you may or may not require to re-architect your application.

For third party applications running your business, there is a chance that the vendor offers the software or the service as a containerized workload. Take WordPress for instance. You can easily run a WordPress website and all its dependencies in an isolated containerized environment. You no longer need to worry about installing and configuring PHP, Apache and MySQL on your physical or virtual machines. Of course, you have the ability to customize the configuration and decouple all the pieces to match your production load.
Depending on your application, you might also be able to run your entire application or service in a container without needing to change much of your code. Take a backend API written in Python or Node.js, for example. You will probably be able to define a Docker file (a file that is used to build and configure a container image with your instructions), create a container image and run the service inside a container.

Running containerized workload at scale in a production environment is operationally complex. Once you are past the experimentation phase and plan to move to production, you will need to adopt and educate your team with a variety of tools such as Kubernetes for container orchestration, CI/CD tools to enable your team to continuously develop, test and deliver changes, monitoring, tracing, alerting and logging tools to be able to track the health of your services and pinpoint immediately what’s going wrong.

Start Strong on Your Cloud Journey

Don’t let complexity and learning curve intimidate you. Sentia has expertise to guide and consult with you throughout this journey. We can work incrementally and take small steps towards migration and container technology adoption.