Choosing a Linux Distribution for Docker Containers | TechWell

Choosing a Linux Distribution for Docker Containers

Linux logo

In the Linux operating system, unlike with virtual machines, each Docker container does not use a complete operating system kernel; multiple Docker containers can share the same one. One of the questions that often arises is which Linux distribution to use as the host operating system.

Let’s look at the factors that govern the choice of a host OS, as well as the Linux to run within a Docker container.

Choosing a Host Operating System

Multiple Docker containers run in isolation on top of Docker Engine, which runs on the underlying host operating system.

Multiple Docker containers running on the same host OS

Each container has its own file system and networking. The host operating system kernel manages lower-level functions such as memory management, file system, networking, and process scheduling. An operating system that provides a kernel optimized for sharing among multiple containers would be the most suitable.

One of the most common choices is Ubuntu, as it provides the latest kernels with the latest capabilities. Ubuntu is derived off Debian OS, which is another common choice for the host OS.

Choosing a Container Operating System

The base operating system, or container operating system, is the OS that runs within a container. A second choice to make is for the Linux distribution to run within a Docker container.

The Linux distribution that runs within a container could be the same or different from the host Linux. Linux containers do not require a base OS, but if software is to be run in a container, a base OS becomes essential.

The base OS could be different for each Docker container

An OS that is small yet provides the essential functionality would be the best choice. Debian provides some variants with a slimmer base, such as buster-slim and 10.3-slim.

A Docker image that makes use of the slimmer edition would have a FROM instruction such as the following at the beginning of the Dockerfile:

FROM debian:buster-slim

The slimmer versions do not include some features and files that are unnecessary for running software within containers—for example, a "slim" Docker image wouldn't include documentation files.

Ubuntu made minimal Docker images available on Docker Hub so that Ubuntu is more suitable as a base OS for Docker images, in addition to being one of the most suitable host OS for Docker.

The Minimal Ubuntu images do not include documentation, editors, locales, or other user-oriented features of standard Ubuntu Server images, and they provide the following benefits:

  • Optimized kernel for cloud use at scale
  • Less than 50% the size of a standard server image
  • Reduced package set
  • Up to 40% faster boot-up time than a standard server image

A Minimal Ubuntu image could be made a base OS image with the Dockerfile instruction:

FROM ubuntu:18.04

Another Docker image commonly used as the base OS image is “alpine,” which is a minimal Docker image based on Alpine Linux, with a complete index for a large selection of packages and a size of only 5 MB. Alpine Linux is small, simple, and secure, and with its quick boot-up time, it is designed specifically for platforms such as Docker containers.

Tags: 

Up Next

About the Author

TechWell Insights To Go

(* Required fields)

Get the latest stories delivered to your inbox every week.