What are Linux containers? | Canonical (2024)

Canonical

Menu Close menu

  1. Blog
  2. Article

What are Linux containers? | Canonical (2)

Miona Aleksic
on 15 March 2022

containers LXC LXD

  • Share on:
  • Facebook
  • Twitter
  • LinkedIn

Over the last decade, containers have become an essential part of running infrastructure more efficiently. Containers enable productivity, automation, and cost-effective deployments. But there are different types of containers to consider, and this blog explains what Linux containers are, and how they differ from application containers.

Photo by Guillaume Bolduc on Unsplash

Application vs system containers

Application containers (such as Docker) are containers running a single process per container. They run stateless types of workloads so that you can ramp up and down as needed – create new containers and delete them at any time. Usually, you don’t need to care about the lifecycle of those containers, as they are meant to be ephemeral.

The other type of containers, system containers, are much closer to a virtual or a physical machine. They run a full operating system inside them, and you manage them exactly as you would a virtual or a physical machine. That means you can install packages inside them, you can manage services, define backup policies, monitoring, and all other aspects as you usually would with a virtual machine. These containers are usually very long-lasting. If you need to update them, you can do so with the normal tooling of the Linux distribution you are using. It also means that you will get normal security updates from distributions for those containers, so you wouldn’t need to wait for any image to be published to get the security fixes.

A walk down the memory lane

System containers are technically the oldest type of containers. It all started in 1999, when BSD introduced jails, a way of running a second BSD system on the same kernel as the main system. That was followed shortly after with a Linux implementation of the concept through Linux vServer. This was a separate project with a big patch set towards Linux kernel aimed at implementing a functionality similar to BSD jails. Soon after, Solaris grew Zones which was the same concept but a part of Solaris OS. OpenVZ project followed, and started to implement multiple VPSs (virtual private servers) on Linux. All of these projects provided system containers that run a full Linux operating system. Both Linux vServer and OpenVZ were not mainline and were pretty big patch sets on top of a Linux kernel. To enable these containers, you needed to install a specific patch set on a specific distribution, and then use additional tools to append containers.

Linux containers

Linux containers, also known as LXC, was the first implementation of system containers that was entirely based on mainline Linux features. This means that you could take a completely clean upstream kernel, or the kernel as distributed by any Linux distribution, and use that to create containers on Linux. LXC itself is a low-level tool that can create both system containers and application containers. Docker was initially based on LXC, which was later replaced by implementing their own runtime.

LXC containers are often considered as something in the middle between a chroot and a full-fledged virtual machine. The goal of LXC is to create an environment as close as possible to a standard Linux installation but without the need for a separate kernel. LXC containers are essentially a copy of an operating system running on the same kernel as its host, so in this case, you don’t virtualise anything, and there are no overhead processes. As far as the kernel is concerned, all processes running in containers are just normal processes on the system, they just happen to have a slightly different view of the operating system.

When should you use Linux containers?

Anytime when you’re running Linux on Linux, you should be considering using containers instead of virtual machines. There’s not much that virtual machines can do that Linux containers cannot. For almost any use case, you could run the exact same workload in a system container and not get any of the overhead that you usually get when using virtual machines. The only exception would be if you needed a specific version of the kernel different from the kernel of the host, for a specific feature of that virtual machine.

System containers are much easier to manage than virtual machines. You see everything that they’re doing directly from the host system and you see all the processes running in them. You can also easily share your file system directly or share specific files, and you can restrict their resource consumption or increase it without having to restart anything. You can pass any device that you have on your host into the container or remove it anytime you want without needing specific hardware, firmware, drivers, or anything else to achieve that. This makes Linux containers an ideal option for both development and production environments, replacing your usual physical or virtual machines.

What is LXD?

LXD is a system container and a virtual machine manager that runs on top of LXC, enhancing the experience and enabling easier control and maintenance. LXD is image-based and provides images for a wide number of different Linux distributions. A simple command-line tool enables you to easily manage your instances, and it is easy to integrate it with third-party orchestration and management tools. LXD can run clusters, it provides support for different storage backends and network types and scales easily from one instance on your laptop to a full rack in a data center.

LXD vs LXC

LXCLXD
– Linux container runtime allowing creation of multiple isolated Linux systems (containers) on a control host using a single Linux kernel

– Only supports containers

– Low-level tool requiring expertise

– System container and virtual machine manager built on top of LXC, enabling easier management, control and integration

– Supports container and VMs

– Better user experience through a simple REST API

TL;DR

Linux containers are system containers that are similar to virtual machines in their behavior and manageability, without the usual VM overhead, and with the density and efficiency of containers. They are suitable for running all types of workloads. With LXD, you can easily run and manage Linux containers, and scale it to suit your needs. For learning more about LXC and LXD visit the website. And in case you would like to try and test LXD follow the steps in this tutorial.

Related posts

Simon Fels
20 March 2024

Implementing an Android™ based cloud game streaming service with Anbox Cloud

Cloud and server Article

Since the outset, Anbox Cloud was developed with a variety of use cases for running Android at scale. Cloud gaming, more specifically for casual games as found on most user’s mobile devices, is the most prominent one and growing in popularity. Enterprises are challenged to find a solution that can keep up with the increasing ...

Miona Aleksic
18 January 2023

Containerization vs. Virtualization : understand the differences

Cloud and server Article

Containerization vs. Virtualization : understand the differences and benefits of each approach, as well as connections to cloud computing. ...

Miona Aleksic
15 March 2024

LXD 5.21.0 LTS is now available

Cloud and server Article

5.21.0 LTS, the stable release of LXD, the system container and VM manager, is now available. ...

What are Linux containers? | Canonical (2024)

FAQs

What are Linux containers? | Canonical? ›

Linux containers, in short, contain applications in a way that keep them isolated from the host system that they run on. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

When to use Linux containers? ›

Anytime when you're running Linux on Linux, you should be considering using containers instead of virtual machines. There's not much that virtual machines can do that Linux containers cannot.

What is containerization in Linux? ›

Containerization, on the other hand, uses compute resources even more efficiently. A container creates a single executable package of software that bundles application code together with all of the related configuration files, libraries, and dependencies that are required for it to run.

What is the difference between Docker and Linux containers? ›

LXC provides a set of tools to manage your container as well as templates to create a virtual environment of the most common Linux OS. Docker is an open-source containerization technology that focuses on running a single application in an isolated environment.

What are Containers used for? ›

Containers are often compared to virtual machines (VMs). Like virtual machines, containers allow you to package your application together with libraries and other dependencies, providing isolated environments for running your software services.

What is an example of a Linux container? ›

LXC is a well-known Linux container runtime that consists of tools, templates, and library and language bindings. It's pretty low level, very flexible and covers just about every containment feature supported by the upstream kernel.

Can Windows run a Linux container? ›

Docker has been able to run Linux containers on Windows desktop since it was first released in 2016 (before Hyper-V isolation or Linux containers on Windows were available) using a LinuxKit based virtual machine running on Hyper-V.

Is Docker a Linux container? ›

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

Is Kubernetes a container? ›

Kubernetes and Docker are both container technologies. Modern applications are made of microservices—independent components that run each application process as a service. Each service performs a single function and communicates with other services via a well-defined interface called API.

What is the difference between Linux container and Linux VM? ›

A container is a software code package containing an application's code, its libraries, and other dependencies. Containerization makes your applications portable so that the same code can run on any device. A virtual machine is a digital copy of a physical machine.

What is Kubernetes vs Docker? ›

While Docker is a container runtime, Kubernetes is a platform for running and managing containers from many container runtimes. Kubernetes supports numerous container runtimes including Docker, containerd, CRI-O, and any implementation of the Kubernetes CRI (Container Runtime Interface).

What is the Linux equivalent of Docker? ›

Podman is an open-source containerization tool and Docker alternative with daemonless architecture, rootless containers, Kubernetes integration and drop-in compatibility with Docker CLI commands. It is ideal for security-conscious developers working with Kubernetes who are familiar with Docker workflows.

What is the difference between Linux containers and Windows containers? ›

The biggest difference is the container image. Windows images are larger than Linux images. When you run your container the Docker image is downloaded and it takes a bit longer than downloading a Docker image based on Linux.

What are the three main types of containers? ›

  • Dry storage container. Dry storage containers are the most common containers used in the shipping industry. ...
  • Flat rack container. A flat rack container has no top and only two sides. ...
  • Open top container. ...
  • Open side storage container. ...
  • Refrigerated ISO containers. ...
  • ISO Tanks. ...
  • Half height containers. ...
  • Special purpose containers.
Mar 26, 2021

What is a container vs VM? ›

Virtual machines provide an abstracted version of the entire hardware of a physical machine, including the CPU, memory, and storage. Containers are portable instances of software with its dependencies that run on a physical or virtual machine.

When would you use a container instead of a VM? ›

VMs solve infrastructure problems by letting organizations get more out of servers and facilitate limited workload portability. Containers solve application problems by improving DevOps, enabling microservices, increasing portability, and further improving resource utilization.

When should I use a VM vs a container? ›

However, virtual machines also provide a high level of isolation, which can be important for security and compliance reasons. Containers are more lightweight and portable than virtual machines. This makes them a good choice for applications that need to be deployed quickly and easily, where compute must be optimized.

When would you use a Docker container? ›

It provides a viable, cost-effective alternative to hypervisor-based virtual machines, so you can use more of your server capacity to achieve your business goals. Docker is perfect for high density environments and for small and medium deployments where you need to do more with fewer resources.

Should I use Windows or Linux containers for Docker? ›

Even though there is no functional difference between Docker on Windows and Linux environments, the installation process on Linux is a bit faster (an apt-get install is quicker than installing a Windows package), and the shell is easier to access on Linux.

Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5808

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.