Introduction to Linux Containers – Part 1

This entry is part 1 of 3 in the series Containers

Author: Chad Vizino, Software Engineer

Over the past year, I’ve had the occasion to use Linux containers (containers) in a software development setting for testing purposes and I have found them to be very useful. However, I was recently introduced to two other interesting use cases and I would like to share them with you.

Let’s say you have an application that you need to run on your compute server, but it requires an older version of Linux than you are currently running. Or, say, you would like to setup a development and execution environment on your personal workstation and then have your application and data run in this exact environment on the server. Do either of these cases fit your need? If so, you may want to consider containers.

what_is_layered_filesystems_sm

Containers provide an efficient way to set up and tear down a prescribed environment in which an application can be executed. Conceptually, containers can be thought of as lightweight virtual machines (VMs) where your application is executed in a separate environment from a host system. Your whole execution environment (operating system, file system, libraries, packages, scripts, application, etc.) can be put in a container and then run on a host system. However, containers differ from VMs in a number of ways. The most significant ones are that a container shares the kernel with the host system, and that a container does not require a hypervisor (an entity that creates and oversees a VM).

These differences are important in the HPC world and other environments where performance is paramount. Even if the hypervisor for a VM is implemented in hardware to minimize performance overhead, you probably do not want to have your application slowed by an additional operating system kernel running under the host system’s kernel. Containers can also be started and stopped in much less time and require much less memory than a VM which leaves more time and memory for your application to run on the host system.

To use Linux containers on your system, it must have a recent Linux kernel. If your system’s operating system software (among others) is Red Hat Enterprise Linux (RHEL) 7 (or one of its compatible distributions) or SUSE Linux Enterprise Server (SLES) 12, it should have a kernel new enough to use containers. A container framework is also necessary to use containers on your system. There are several frameworks to choose from but Docker is presently the most popular.

Docker provides a convenient way to package all the dependencies of an application into an image that can be run within a container on a host system or moved to another system and run there. Once you’ve bundled all your software and dependencies into an image it can be run, providing a predictable environment each time. Additionally, you can share the image with someone else to run. Docker provides a very nice repository or registry called Docker Hub, where you can share or download images. On Docker Hub you will find images for most mainstream Linux distributions as well as custom images others have uploaded. Once you find the distribution you want, you can download it, customize it to your needs and save it as a new copy, which can be used by you or others in the future.

Containers provide a very convenient way to set up an environment with a specific set of software requirements that may differ from the host system. Containers also have much less overhead than a virtual machine. If containers seem like a good fit for your needs, Docker provides a very nice framework for managing them. In a future article, I’ll go into more details about using Docker and how you might use it to help solve your need for a custom environment to run your application.

Series NavigationAn Introduction to Basic Docker Commands >>
Facebook Twitter Email