What are Containers?

Containers are defined as packages of software where the application code, libraries, and dependencies are bundled together and can be run in any environment; on desktop, cloud, or traditional IT. In other words, containers can be moved from one computing environment to another freely. For instance, from a personal computer to a virtual machine whether in the private or public cloud. Notably, a discrete environment in an operating system is set where applications are run and mostly assigned the only necessary resources they need to function accordingly. In this guide, we will go through Linux operating system containers, and how to install and run them with LXC/LXD on Solus.

Linux Containers

Linux Containers are a set of one or many processes that are isolated from the rest of the Linux system. When we talk about Linux containers, we focus on two key terms; LXD and LXC.

What is LXC?

LXC(an acronym for Linux Containers projects) is a platform that has a set of tools, libraries, templates, and languages. Also, it is a command-line interface that gives the user experience when they first start with containers. The theory behind LXC is almost the same as that of virtual machines only that containers run at the operating system level while virtual machines work at the hardware level. Linux Containers assist the applications to gain the container technology, especially in isolation, configurations or porting. With LXC you are guaranteed that applications will run correctly on each system without the need for a separate kernel. Additionally, LXC can start and stop larger containers and make changes to their environment variable.

Components and Features of LXC

  • Languages binding for the API(Python, Go, Lua, Ruby, or Haskell)
  • Liblxc library
  • Set of tools to control the containers
  • Distribution containers templates

LXC Features

  • Kernel capabilities
  • CGrpougs: These are the control groups
  • Kernel namespaces:ipc, uts, mount, pid, network, and user
  • SecComp policies: Secure computing mode available in the Linux Kernel
  • Chroot: Can modify the working root directory for the current process
  • AppArmor and SELinux-Profile

What is LXD?

LXD (Linux Container Daemon) is the background service that manages Linux operating system containers. Originally, LXD was developed by a company known as Canonical. It is a representational state transfer application programming interface(REST API) responsible for communicating with LXC through the liblxc library. It provides the system daemon that applications use to access LXC.LXD has a template distribution system that allows faster container creation and operation.

Features of LXD

  • Enables live migration of running application between hosts
  • A highly capable command-line interface
  • Has powerful storage and network capabilities
  • Enhanced compute resources control
  • Highly scalable
  • Security: Has unprivileged container settings and resource restrictions.
  • Consists of snapshots of running containers

How To Install LXC/LXD on Solus Linux

Follow the steps below to install and configure LXC/LXD on Solus Linux.

Step 1: Install LXD on Solus Linux

To start your journey on Linux containers, you are supposed to install LXD. However, before you start the installation process, ensure that your Solus system repositories are up-to-date. Key in the following command on your terminal.

a. Updating Repository

Run the following command to ensure your package repository is updated.

sudo eopkg up

b. Install Snap

In Solus, we will use Snap, a package manager, which will help us in the installation of LXD. Hence, let’s first install Snap in our system.

sudo eopkg install snapd

After the installation of snap, enable the systemd unit meant for managing the snap communication socket.

systemctl enable --now snapd.socket

You can confirm that snap is up and running using this command.

sudo systemctl status snapd.socket

Here is the output denoting that snap is ready for usage.

● snapd.socket - Socket activation for snappy daemon
     Loaded: loaded (/usr/lib/systemd/system/snapd.socket; enabled; vendor pres>
     Active: active (listening) since Sat 2022-05-02 23:23:05 EAT; 31min ago
   Triggers: ● snapd.service
     Listen: /run/snapd.socket (Stream)
             /run/snapd-snap.socket (Stream)
      Tasks: 0 (limit: 4647)
     Memory: 0B
        CPU: 332us
     CGroup: /system.slice/snapd.socket

Reboot Solus operating system to finalize the installation process.

sudo reboot -i

c. Install LXD using Snap

Now, we will install LXD on Solus using the snap we have already installed.

sudo snap install lxd

The output after installing LXD is as shown below.

lxd 5.0.0-b0287c1 from Canonical✓ installed

LXD has been installed successfully.

Step 2: Check LXD Version

After the installation of LXD, you can check its version by running the below command.

lxd --version

Here is the result of the LXD version.

$ lxd --version

Step 3: Add user to LXD Group

To make the usage of LXD easier, add a user to the LXD Group. Using the command below, LXD will automatically add the current user to the LXD Group. In case you want to change that, replace the word $USER with a preferred name.

sudo usermod -aG lxd $USER

To verify that the user was added to the LXD group, type these commands.

id -nG

Here is the output indicating the current user has been added to the LXD group.

$ id -nG
lxd sudo  maryndungu

Step 4: Initialize LXD on Solus Linux

Let’s Initialize or configure LXD so to ensure it is working accurately.

lxd init

After keying in the above, you will be asked to answer a couple of Yes/No questions. Also, you can choose the default answer by hitting the enter button after every question.

Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]:     
Name of the new storage pool [default=default]: 
Name of the storage backend to use (btrfs, dir, lvm, ceph) [default=btrfs]: 
Create a new BTRFS pool? (yes/no) [default=yes]: 
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]: 
Size in GB of the new loop device (1GB minimum) [default=11GB]: 
Would you like to connect to a MAAS server? (yes/no) [default=no]: 
Would you like to create a new local network bridge? (yes/no) [default=yes]: 
What should the new bridge be called? [default=lxdbr0]: 
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
Would you like the LXD server to be available over the network? (yes/no) [default=no]: 
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: 
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:

Creating and Running Containers using LXD on Solus

Even though we are technically using the LXD interface, we will use the lxc command to install and configure Linux Containers.

a) Creating Linux Containers

Let’s apply the lxc launch command to create Linux containers. In the below syntax, fill in the details of a Linux distribution including its name, version, and arch.

lxc launch images:{distro}/{version}/{arch} {container-name-here}

As for the Image, I will select one that exists (e.g ubuntu/20.04/amd64) in a public repository. Type any preferred container name(e.g SolusFortitude).

lxc launch images:ubuntu/20.04/amd64 SolusFortitude

Here is the output after launching SolusFortitude as our container.

$ lxc launch images:ubuntu/20.04/amd64 SolusFortitude
Creating SolusFortitude
Starting SolusFortitude 

b) View Linux Containers Information

Check the details of the existing Linux containers using these commands.

  • List Command
lxc list

You will see the name, status, and IP Versions for your containers.

$ lxc list
|      NAME      |  STATE  |        IPV4         |                     IPV6                      |   TYPE    | SNAPSHOTS |
| SolusFortitude | RUNNING | (eth0) | fd42:8d54:9e4a:22e6:216:3eff:feb1:e226 (eth0) | CONTAINER | 0         |

Apart from listing running containers, you can also list any storage pools.

$ lxc storage ls
|  NAME   | DRIVER |                   SOURCE                   | DESCRIPTION | USED BY |  STATE  |
| default | btrfs  | /var/snap/lxd/common/lxd/disks/default.img |             | 3       | CREATED |
  • Info Command

Verify the information of a specific container.

lxc info 

Add the name of a container after the above command to see detailed information about the container.

$ lxc info SolusFortitude
Name: SolusFortitude
Type: container
Architecture: x86_64
PID: 3252
Created: 2022/05/01 21:24 EAT
Last Used: 2022/05/01 21:24 EAT

  Processes: 13
  CPU usage:
    CPU usage (in seconds): 0
  Memory usage:
    Memory (current): 92.44MiB
  Network usage:
      Type: broadcast
      State: UP
      Host interface: vethcfc39c62
      MAC address: 00:16:3e:b1:e2:26
      MTU: 1500
      Bytes received: 3.93kB
      Bytes sent: 2.98kB
      Packets received: 29
      Packets sent: 29
      IP addresses:
        inet: (global)
        inet6: fd42:8d54:9e4a:22e6:216:3eff:feb1:e226/64 (global)
        inet6: fe80::216:3eff:feb1:e226/64 (link)
      Type: loopback
      State: UP
      MTU: 65536
      Bytes received: 0B
      Bytes sent: 0B
      Packets received: 0
      Packets sent: 0
      IP addresses:
        inet: (local)
        inet6: ::1/128 (local)
  • Help Command

In case you have to face any challenges with LXC commands, you can use the — help command to guide you through.

lxc --help

You will find the commands used in Linux containers.

$ lxc --help
Command line client for LXD
lxc [command]
Available Commands:
alias Manage command aliases
cluster Manage cluster members
config Manage instance and server configuration options
console Attach to instance consoles
copy Copy instances within or in between LXD servers
delete Delete instances and snapshots
exec Execute commands in instances
Use "lxc [command] --help" for more information about a command.

c) Execute a command in LXD

Use the lxc command to run and execute commands in a given container. For instance, you can open a session using the “lxc exec” command, followed by the container name and the list command; to show the computer directories.

$ lxc exec SolusFortitude ls /
#SolusFortitude is the container name


$ lxc exec SolusFortitude ls /
bin   dev  home  lib32	libx32	mnt  proc  run	 srv  tmp  var
boot  etc  lib	 lib64	media	opt  root  sbin  sys  usr

Install and use LXD Web UI on SOlus

Instead of using a command line to manage Linux Containers, you can use LXD Web User Interface. In this case, we will install and use LXD Mosaic to assist with handling containers and instances.

Install LXD Mosaic on Solus

Use the following command to install LXD Mosaic using the snap package manager.

sudo snap install lxdmosaic

It will install successfully and give the below results.

$ sudo snap install lxdmosaic
lxdmosaic 0+git.2124524 from Daniel Hope (turtle0x1) installed

Set the Apache port that LXD Mosaic will listen on.

sudo snap set lxdmosaic ports.http=81 ports.https=444

Now, set the password you will use for LXD User Interface.

lxc config set core.trust_password

Enter your preferred password. For example, I will set Container123 as my password. After typing the password, click on the Enter button.

lxc config set core.trust_password Enter your password Container123

Since we have installed LXD Web User Interface (which in our case is LXD Mosaic) let’s go ahead and restart snap.

sudo systemctl restart snapd

Accessing LXD Web User Interface

We will access LXD Mosaic using this link: https://IP_address:444 on a browser. Replace the name IP_adress with the IP address of your computer.LXD Mosaic will open as illustrated below.

On the host’s section, type the IP address you used on the link and the password you set for LXD Mosaic. On the User’s part, create a password you will remember. Then click on the Launch LXD Mosaic button. Use the Users login details to sign in to LXD UI.

After signing in, you will be directed to the LXD Mosaic dashboard where you will continue managing your containers.


Linux Containers are paramount in the world of computers. Bear in mind that these containers are bundled up with application code together with necessary configurations and libraries. With LXD/LXC; which are the main terms used in Linux Containers, we are free to create, run and use containers on Solus operating system. This guide has taken you through the installation and usage of LXD/LXC on Solus and how you will create and manage containers using lxc commands.

Additional Resources:


Please enter your comment!
Please enter your name here