All Articles

Support Articles

Table of Contents

Containers on Linux

Sometimes, an older version of a library or libraries for an application is needed for development. It is faster and easier to use LXC/LXD to set up a container of that release and work in that container.

Software

First, open a terminal using the keyboard shortcut for your operating system:

Pop!_OS : SUPER + T

Ubuntu : CTRL+ALT+T

Install the software by running these commands in the terminal:

sudo apt install snapd
snap install lxd

Setup

Add your current user to the lxd group so that it has the correct permissions to use the application:

sudo usermod -aG lxd $USER

Reboot to apply the new permissions, then open a terminal again and set up LXD's storage and network configuration with this command:

lxd init

Create a container

Now, create your first container with this command:

lxc launch ubuntu:16.04 ubuntu-container

This will create a container based on Ubuntu 16.04 with the name 'ubuntu-container'. You can change the version depending on the OS version that you need. For example, for Ubuntu 18.04:

lxc launch ubuntu:18.04 ubuntu-container

Or for Ubuntu 20.04:

lxc launch ubuntu:20.04 ubuntu-container

List and confirm that the container was created with this command:

lxc list

The container can be stopped with this command:

lxc stop ubuntu-container

Or the container can be deleted:

lxc delete ubuntu-container

Enter the container

Enter the container with this command:

lxc exec ubuntu-container -- /bin/bash

Or just one command can be issued without entering the container:

lxc exec ubuntu-container -- apt update

Sharing files

To push a file to the container:

lxc file push filename first/tmp/

To pull a file from the container:

lxc file pull first/tmp/filename .

For more information, refer to Ubuntu's documenation.