Containers 101: Linux containers and Docker explained

A brief introduction to lightweight, portable, flexible Docker containers and why developers love them

Linux cgroups, originally developed by Google, govern the isolation and usage of system resources, such as CPU and memory, for a group of processes. For example, if you have an application that takes up a lot of CPU cycles and memory, such as a scientific computing application, you can put the application in a cgroup to limit its CPU and memory usage.

.. The original Linux container is Linux Containers, commonly known as LXC. LXC is a Linux operating system-level virtualization method for running multiple isolated Linux systems on a single host. Namespaces and cgroups features make LXC possible.

.. To run a simple multitier Web application in Docker, you would need a PHP container, an Nginx container (the Web server), a MySQL container (for the database process), and a few data containers for the database storage and other application data.

The advantages of single-process containers are many, including easy and more granular updates. Why shut down the database process when all you wanted to update is the Web server? Also, single-process containers represent an efficient architecture for building microservices-based applications.

There are also limitations to single-process containers. For instance, you can’t run agents, logging scripts, or an SSH daemon inside the container. Also, it’s not easy to commit small, application-level changes to a single-process container. You are essentially forced to start a new, updated container.

.. First, Docker does not support persistent storage. Docker gets around this by allowing you to mount host storage as a “Docker volume” from your containers.

.. A direct benefit of this approach is that Docker enables developers to set up local development environments that are exactly like a production server. When a developer finishes writing and testing his code, he can wrap it in a container and publish it directly to an AWS server or to his private cloud, and it will instantly work because the environment is the same.