TimurD - Fotolia

Tip

Use LinuxKit to increase container portability

With LinuxKit, Docker continues its push for better container portability. Learn how the tool can help your apps run across various platforms, as well as its potential limitations.

While application portability is one of the biggest benefits of containers, there's been room for improvement. And, to address some of its portability limitations, Docker introduced LinuxKit, an open source tool that helps dev teams create container-based applications that are as portable as possible.

LinuxKit explained

With LinuxKit, developers can build custom Linux distributions to host containerized applications. These distributions only require minimal system resources to run. They are also immutable, which means that most components inside the OS are unable to change while it runs and developers can use code to automatically configure the OS.

A minimalist Linux distribution to host containers is not a new concept. Alpine Linux, a popular distribution for hosting Docker workloads, and RancherOS, a Docker-oriented distribution created for Rancher's containers-as-a-service platform, both have a lean approach. However, LinuxKit is different from these OSes in three main ways:

  • It's not a Linux distribution itself; it's a tool to create one.
  • It offers immutability and automation features.
  • It produces a Linux distribution that runs directly inside a container.

App portability

LinuxKit is an ideal tool to build highly portable containerized applications. Because of the third feature described above, the tool simplifies deployment and enables developers to easily add an application to the container to create a fully functioning, self-contained application and execution environment. Developers can then launch this environment on a variety of hypervisors and cloud platforms with a few commands.

For example, LinuxKit container images can run on:

  • HyperKit on macOS
  • Hyper-V on Windows
  • QEMU
  • VMware
  • AWS
  • Google Cloud Platform
  • Azure
  • Packet
  • private clouds built with OpenStack
  • bare-metal servers

Traditionally, if you wanted to deploy a Docker container, you would have to install Docker and a Docker-compatible OS on the host server or cloud platform. Because LinuxKit includes a host OS and execution environment inside the container, extensive provisioning of the host server is not necessary. You simply run the container you created with LinuxKit.

Get started with LinuxKit

The easiest way to install LinuxKit in a platform-agnostic way is to use Go. With Go installed, you can install LinuxKit from any OS using this command:

go get -u github.com/linuxkit/linuxkit/src/cmd/linuxkit

After you install LinuxKit on your system, you can use pass arguments to it to generate container images that have customized Linux distributions built in. The basic usage is:

linuxkit build image-name.yml

Here, image-name.yml is the name of the YAML file that corresponds to your new container image.

For a summary of the arguments that you can pass to LinuxKit to customize the format of the YAML file that it generates, run:

linuxkit build -help

Once you build your image, you can run it with:

linuxkit run image-name

Here, image-name is the name of the image that you created in the build step above.

You can also move the container image to another server to run. In addition, you can modify the YAML file that LinuxKit generated to customize the image further.

Tips and caveats

The main limitation of LinuxKit is that it only supports the creation of Linux-based container images. If you want to run a native Windows application inside a container, LinuxKit won't help, because Windows applications can't run inside a Linux-based environment. However, it is possible to use LinuxKit to help run containerized Linux applications on certain versions of Windows via Linux Containers on Windows -- although, this remains experimental.

LinuxKit is also not ideal if you want the OS that hosts a containerized application to do more than the bare minimum required to run the app. In many cases, though, the bare minimum is exactly what a developer or admin wants; anything more could lead to wasted resources and potential security vulnerabilities.

If you want a full-fledged Linux distribution that enables you to easily log in, add software or modify configurations packages dynamically, the OS that LinuxKit produces is a poor fit. A better option would be a more traditional approach with a distribution such as Alpine or RancherOS, or perhaps even a heavier-weight system -- such as Ubuntu -- to host your containerized applications.

Dig Deeper on Cloud app development and management

Data Center
ITOperations
SearchAWS
SearchVMware
Close