The ELinOS embedded Linux distribution supports Docker by means of software distribution. This tutorial showcases a setup process of a Node.js web server embedded in a Docker image, running on an ELinOS-based Linux system.
Introduction
Docker is a set of tools and services that use OS-level virtualization to execute software. The software is distributed in form of images – packages which contain the software itself, all the necessary libraries and configuration files. The host operating system/kernel executes those as so called “containers”. While those are technically self-sufficient, it’s possible to define communication channels which can be used to orchestrate software into bigger groups of independent components.
While Docker can be also executed on Windows, in context of ELinOS, a Linux kernel is used. There, Docker uses several kernel features to implement the virtual machines. Among others, they enable management of CPU/memory resources (cgroups), network (netfilter) and storage (overlayfs). Using the kernel namespace support, also the operating system environment is virtualized – including process trees, user IDs, mounted filesystems etc.
Benefits
This lightweight nature of the containers allows better scaling – running many services in parallel is easily possible, as opposed to traditional full-blown virtualization, where the whole operating system including the kernel is virtualized. Additionally, compared to the traditional Unix package-based software management, the images can easily use the same libraries of different versions, which may be advantageous for simple setup.
There are several ways to prepare the software images. The simplest one is taking one of the 3.8+ million community-provided images (or 500+ from official/verified publishers) – this covers the most widely used software like web servers, databases and various micro-services. The docker tools also allow building custom images, while the most basic image can even be a ELinOS filesystem.
The containers are often designed stateless, in which case updating them is a question of downloading the new version and restarting the service. The simple update process also improves security – if the components are configured correctly, the update can be performed seamlessly.
The Docker images (and containers) are independent on the environment/packages provided by ELinOS. This makes ELinOS a suitable platform for running Docker-based software. Even the Docker registry (image storage server) is provided as a image, and thus custom hosting can be setup – without the need to use the public services.
Integration in ELinOS
To showcase the usage of Docker within ELinOS, we will be using a clean Node.js environment, which is part of the Docker base library. A minimal http server will be integrated. While it’s possible to use various packages from NPM, only the base Node component will be used for simplicity.
System Project Setup
System image preparation in ELinOS starts by choosing the base configuration of the project – either one of the pre-configured templates can be used, or an empty configuration with just a few options enabled. This enables to minimize the system size – which helps both security and quick deployment. CODEO tool will used in the following example – which is a GUI configuration tool based on Eclipse.