What Is Container Linux and Should You Use It?
Linux operating systems come in a variety of flavors. Whereas Linux operating systems such as Ubuntu are fairly general, still others target a niche. There’s the security-oriented Kali Linux. Lightweight distributions such as Xubuntu, and even Hannah Montana Linux(!). For desktop use, a vanilla Linux operating system functions well. However for specialized tasks like running a server, it’s best to find a tailored version.
Containers are increasingly popular. Container Linux, formerly known as CoreOS, is a Linux operating system designed for simple containerized deployments. It’s one of the newest niche Linux operating systems . Check out this overview and hands-on look at Container Linux.
Hands-On With Container Linux: Background Knowledge
Before diving into Container Linux, let’s begin with a brief overview of server architecture. Container Linux is designed for clustered deployments. A clustered deployment sounds quite complex, but it’s rather simple. Essentially, a computer cluster is comprised of multiple servers that work together. Therefore, they function as one unit or system rather than multiple. Furthermore, computers in a cluster feature nodes, or servers, that perform the same function. So a node is a single machine while a cluster is a group of servers that work together.
Most common Container Linux deployments are within cluster environments. The distro formerly known as CoreOS even includes the means to spin up a cluster from just one machine. The defining feature of Container Linux, however, is its reliance on containers.
Unlike a traditional desktop operating system, all applications run in containers. While both virtual machines (VM) and containers use virtualization methods, containers differ. Unlike VMs, containers utilize the same operating system kernel as the host machine. Because containerized apps and the host machine use the same kernel, container deployments benefit from increased efficiency. In a virtual machine configuration, each VM runs an app plus a guest operating system. This runs on top of the host operating system and hardware.
Containerized deployments instead run apps in their own containers on top of virtualization software. Docker remains the most popular container software, though chroot, LXC, and Linux-VServer rank among Docker alternatives.
Hands-On With Container Linux: Why Use Containers?
OK, so containers are a virtualization method. Why opt for a containerized environment? Typically containers deliver improved performance. By eschewing separate operating systems and instead using a shared kernel, you maximize CPU, storage, and memory efficiency.
Since you don’t need to run multiple operating system instances like you would in a VM configuration, you can run more containers. Performance enhancements derive from the need for a single operating system. Similarly, you can create containers faster than in a virtual machine environment. Therefore containers are more suited to maintaining agility and allowing for continuous delivery and continuous integration.
Agile development concentrates on iteration and factoring in unpredictability. You can read the Agile Manifesto for further insight into the agile philosophy. However despite the advantages of containers, its not a perfect virtualization method. As containers share the host operating system kernel, there’s a security risk. Any vulnerability or breach that affects a container gains access to the operating system. But there’s a workaround of running containerized apps on an operating system within a virtual machine. This ensures that the host machine operating system is isolated from the singular container host operating system.
Containerization also requires that containers use the same operating system. With virtual machines, each application gets its own operating system. So you can’t run apps designed for Windows Server in a containerized Linux environment and vice versa.
Hands-On With Container Linux: What Is Container Linux?
CoreOS, or Container Linux as it’s now called, is an open-source Linux operating system. It’s a lightweight distro aimed at clustered deployments. More specifically CoreOS concentrates on simple, reliable, scalable deployments. You won’t find a package manager. Instead Container Linux requires all apps to run inside containers. Container Linux uses Chrome OS as its base. Therefore, Container Linux remains pretty lightweight. To test, I ran the Linux operating system formerly known as CoreOS in a virtual machine on an aging HP Envy m6-1205dx AMD A10-powered laptop. System resource consumption stayed fairly low.
Because Container Linux eschews several traditional desktop Linux operating system features, it keeps the distribution lightweight. Unlike a desktop operating system, you won’t find a package manager. Instead, all applications run as Docker containers. This makes for portability and service isolation. If you want a desktop environment, you’re out of luck. Container Linux lacks a graphical user interface. Instead, everything is command line based. The CoreUpdate dashboard does offer information on machine health, running services, and cluster health. But it’s only available as a component in the Premium Managed Linux subscription.
Container Linux Architecture
Container Linux is lightweight and designed for containerizing and clustering. Since there’s no desktop environment, configuration functions differently than on a Linux operating system like CentOS or Ubuntu. Upon initial boot, Container Linux loads a cloud-config file. You’ll need to input information in cloud-config. This can be a bit tricky, especially for those not familiar with cloud-config. But it’s an essential file that gives Container Linux its ability to load essential services, alter parameters, and manage clusters.
fleet daemons remain integral to Container Linux. Both of these services launch at startup by default. Additionally, at boot the cloud-config file lets the host know how to join an existing cluster. The
etcd daemon distributes and stores data for hosts within a cluster. It’s essential for maintaining configurations as well as service discovery. The
fleet daemon is similar to a distributed init. This daemon links to the
systemd init for hosts in a cluster and takes care of tasks like service scheduling.
Each system in a
fleet cluster runs only one
fleetd daemon. This daemon assumes two main responsibilities acting as both agent and engine. As the engine, the daemon performs scheduling decisions. Whereas the agent side executes units. In the fleet cluster,
etcd is the only datastore. Such information like cluster presence, unit state,and unit files are all stored within the
etcd daemon. Additionally, it’s the medium for fleet agent and engine communication.
Hands-On With Container Linux: Who Should Use It?
Container Linux is free to download, lightweight, and fairly simple to install in a virtual machine. Anyone who needs quick, scalable, containerized deployments should opt for Container Linux. Mostly system administrators and database administrators will benefit the most from Container Linux. As Container Linux lacks a desktop environment, it’s best suited for cluster management and in a server setting. If you’re looking for a Linux server operating system, Container Linux is one of the 12 best Linux server distro s.
Air Pair features an excellent write up on CoreOS incentives. This article mentions high availability, production environment maintenance, software version control, and the etcd as main draws for using Container Linux. Notably, there’s also an incredibly dedicated open-source community. Container Linux is tailored for seasoned Linux users. The help documentation while comprehensive does assume a moderate degree of Linux familiarity. Novice and beginner users might have a bit of trouble with the initial installation.
More specifically, cloud-config may be a challenge. In the comments section of one CoreOS installation video, YouTube user Setyoso Nugroho stated, “Nice tutorial! Quite confusing when learning #cloud-config file configuration in CoreOS.” While the configuration isn’t terribly difficult, Container Linux assumes a strong grasp of Linux features like the VIM editor.
Hands-On With Container Linux: How to Install
There are many means to install Container Linux. According to the CoreOS website, official platforms include Amazon EC2, DigitalOcean, Microsoft Azure, bare metal, and OpenStack. Alongside the likes of Oracle Linux, CentOS, and Suse, CoreOS is one of a handful of Azure compatible Linux operating systems . Thanks to a vibrant community, platforms such as Packet, Rackspace, Brightbox, VirtualBox, and VMware are supported as well. I found the easiest method was installing Container Linux on VirtualBox using an ISO file. Here’s a quick guide for how to use VirtualBox .
Open VirtualBox and you’ll be prompted for a virtual machine name, operating system type, and version. I called mine simply CoreOS. For the type, select Linux. As version, use Linux 2.6/3.x/4/x (64-bit). Click Next.
Now you’ll need to allocate your RAM. CoreOS suggests a minimum of 1024 MB of RAM.
After selecting your RAM, you’ll need to add a virtual hard disk. Use the create a virtual hard disk now option.
On the next screen, you’ll be prompted for a hard disk file type. Select VDI, or VirtualBox Disk Image.
After that, configure your storage space. I recommend using a dynamically allocated hard disk file.
Then choose the file location and size. I left the default CoreOS as the name, and opted for an 8 GB file data size.
With your CoreOS VirtualBox virtual machine properly configured, go ahead and click the green Start button.
Once you click Start, you’ll need to select a start-up disk. Navigate to the folder where you’ve got your CoreOS ISO and continue.
Configuring Container Linux
After starting your CoreOS ISO, Container Linux begins to load. You’ll eventually see a line gives your CoreOS version and a command line reading:
sudo openssl passwd -1 > cloud-config-file
The command line presents a warning that if can’t open the config file. Enter your desired password and continue. Next enter:
This returns a long string and creates a new cloud-config file. Now open the cloud-config in a visual editor:
This loads a cloud-config file that you can edit. CoreOS includes an advanced cloud-config example file:
Mine looked like:
#cloud-config users: moe passwd: [SSL password] groups: - sudo - docker
You can check your cloud-config file by entering:
This returns your config file. If all looks good, proceed with installing CoreOS:
sudo coreos-install -d /dev/sda -C stable -c cloud-config-file
You’ll see a message that CoreOS is being downloaded, written, and verified. As soon as that finishes, you’ll see a message that says “Success! CoreOS [version] is installed on /dev/sda.”
Shutdown your CoreOS virtual machine and then start it back up. When starting back up, be sure to unmount the CoreOS ISO or else the live CD will run again.
CoreOS will load and you’ll a login prompt in the command line:
Enter your username and password. This will load a message that says “Container Linux by CoreOS [version]” and a fresh command line.
Hands-On With Container Linux: Next Steps
Now that Container Linux by CoreOS is properly installed, you can begin setting up containers and clusters. CoreOS documentation features an excellent quickstart guide. There’s information about service discovery using etcd as well as a section on container management with Docker. I performed a few quick tests such as a “Hello World” Docker pull. Additionally, I installed a Plex Docker image because I’m a big media server buff. Finally, I set up fleet for cluster management.
What you’ll want to do first is configure the main components of Container Linux:
By configuring these three primary foundations, you’ll be ready for service discovery, cluster management, and setting up containers. Then you can get started containerizing apps and safely testing desktop apps in a secure Docker container .
Hands-On With Container Linux: Final Thoughts
I don’t use containers often, but Container Linux simplified deployment. Documentation is excellent with sample config files. Note that for beginners, several unofficial video installation tutorials make CoreOS installs easier. While CoreOS claims that Container Linux is lightweight, I was initially skeptical. Yet I spun up Container Linux in a virtual machine with fairly low resource consumption. And because I wanted to test if Container Linux was truly lightweight I used my aging HP laptop, and encountered no issues.
However, some steps in the initial installation aren’t very “beginner friendly.” Installing and setting up Container Linux requires a robust Linux familiarity. Notably I didn’t try the CoreUpdate dashboard, which CoreOS offers as a paid premium feature. While I have no problems using the command line, a graphical environment for monitoring would make a nice addition.
System administrators and database admins benefit the most from Container Linux. However for home servers, it’s a simple and lightweight means of creating a clustered environment. Moreover, with Container Linux you can spin up a cluster from a single machine. But Container Linux is a great introduction to working with containers. If you’re trying to learn more about Docker and containers, Container Linux runs really well in a virtual machine and offers all the resources you need to get started.
It’s an excellent out-of-the-box solution for Container novices in addition to seasoned DevOps engineers, sysadmins, and database admins. Ultimately Container Linux by CoreOS is a simple means of creating a scalable, efficient, containerized environment.
Are you using CoreOS? Do you plan to? Let us know how you’re containerizing on Linux in the comments section below!