LXC Containers LXD How to Install and Configure Tutorial Ubuntu Debian Mint

If you are using mint, delete the preference that stops snap from installing (as it is required for lxc)

sudo rm /etc/apt/preferences.d/nosnap.pref
 

1. Install lxd:

sudo apt install lxd

Issues install lxd or errors? Click here

Debian at this time does not have lxd so you'll need to use snap:

sudo apt install snapd && sudo snap install core && sudo snap install lxd

*Restart your terminal/SSH session otherwise lxd won't work/be found in the PATH

 2. Configure lxd

lxd init

#defaults are normally fine

You may want to consider changing storage backend to use "dir" which literally means in the existing userspace, rather than relying on loopback devices with a fixed size (eg. like 30GB we made below).

3.) List Available Images for LXC

#note the colon : at the end below, it is needed or it won't show the available images, but rather images on your machine already which will be none at this point

lxc image list images:

This will show ALL images but perhaps it's not what you want, maybe you just want to see what Debian or Ubuntu is available?

lxc image list images:debian:

There's still a lot of images, let's just say we wanted only Debian 10 images shown?

sudo lxc image list images:debian/10

 

4.) Create our first Debian 10 container!

lxc launch images:debian/10 gluster01
Creating gluster01
Starting gluster01        
                  

The above creates a container called "gluster01" with the image "debian/10"

5.) Working with lxc

How can we see what containers are running and what their IPs are?

lxc list

 

Now you can enter and work with gluster01 like this:

Replace gluster01 with your container name.

lxc exec gluster01 bash

 

 

How to Make Config Changes to LXC Containers?

The command below is going to edit the config of container "gluster01" and enable the features security.nesting and security.privileged for more features for other applications like docker.

lxc config set gluster01 security.nesting=1 security.privileged=1
 

 

Issues installing lxd?

snap lxd install error:

snap install lxd
error: cannot perform the following tasks:
- Mount snap "lxd" (23339) (snap "lxd" assumes unsupported features: snapd2.39 (try to update snapd and refresh the core snap))

This will fix it:

snap install core

snap install lxd --channel=latest/stable
Warning: /snap/bin was not found in your $PATH. If you've not restarted your
         session since you installed snapd, try doing that. Please see
         https://forum.snapcraft.io/t/9469 for more details.

lxd 5.4-82d05d6 from Canonical✓ installed

 

 

Make sure that you use the 4.0 or newer track, as 3.0/older is usually not supported/non-existent and will cause the install to fail:

==> Installing the LXD snap from the 3.0 track for ubuntu-20.2
error: requested a non-existing branch on 3.0/stable for snap "lxd": ubuntu-20.2

Manually install with snap like this to fix it/solution:

snap install lxd --channel=latest/stable

2022-05-20T14:12:05-07:00 INFO Waiting for automatic snapd restart...
lxd 5.1-1f6f485 from Canonical✓ installed



Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  snapd
The following NEW packages will be installed:
  lxd snapd
0 upgraded, 2 newly installed, 0 to remove and 377 not upgraded.
Need to get 34.3 MB of archives.
After this operation, 147 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 snapd amd64 2.54.3+20.04.1ubuntu0.3 [34.3 MB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 lxd all 1:0.10 [5,532 B]
Fetched 34.3 MB in 3s (12.0 MB/s)
Preconfiguring packages ...
Selecting previously unselected package snapd.
(Reading database ... 422832 files and directories currently installed.)
Preparing to unpack .../snapd_2.54.3+20.04.1ubuntu0.3_amd64.deb ...
Unpacking snapd (2.54.3+20.04.1ubuntu0.3) ...
Setting up snapd (2.54.3+20.04.1ubuntu0.3) ...
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.apparmor.service → /lib/systemd/system/snapd.apparmor.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.autoimport.service → /lib/systemd/system/snapd.autoimport.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.core-fixup.service → /lib/systemd/system/snapd.core-fixup.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.recovery-chooser-trigger.service → /lib/systemd/system/snapd.recovery-chooser-trigger.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service.
Created symlink /etc/systemd/system/cloud-final.service.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.service → /lib/systemd/system/snapd.service.
Created symlink /etc/systemd/system/timers.target.wants/snapd.snap-repair.timer → /lib/systemd/system/snapd.snap-repair.timer.
Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /lib/systemd/system/snapd.socket.
Created symlink /etc/systemd/system/final.target.wants/snapd.system-shutdown.service → /lib/systemd/system/snapd.system-shutdown.service.
snapd.failure.service is a disabled or a static unit, not starting it.
snapd.snap-repair.service is a disabled or a static unit, not starting it.
Selecting previously unselected package lxd.
(Reading database ... 422929 files and directories currently installed.)
Preparing to unpack .../archives/lxd_1%3a0.10_all.deb ...
=> Installing the LXD snap
==> Checking connectivity with the snap store
==> Installing the LXD snap from the 3.0 track for ubuntu-20.2
error: requested a non-existing branch on 3.0/stable for snap "lxd": ubuntu-20.2
dpkg: error processing archive /var/cache/apt/archives/lxd_1%3a0.10_all.deb (--unpack):
 new lxd package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/lxd_1%3a0.10_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

 


Tags:

lxc, containers, lxd, install, configure, tutorial, ubuntu, debian, mintif, mint, delete, preference, installing, sudo, rm, etc, apt, preferences, nosnap, pref, errors, init, defaults, backend, quot, dir, existing, userspace, relying, loopback, devices, eg, gb, images, colon, container, gluster, creating, creates, ips, exec, bash, newer, supported, existent, requested, manually, info, snapd, restart, canonical, installed, lists, dependency, additional, packages, upgraded, newly, mb, archives, disk, http, archive, focal, updates, amd, fetched, preconfiguring, selecting, previously, unselected, database, directories, currently, preparing, unpack, snapd_, _amd, deb, unpacking, symlink, systemd, multi, user, apparmor, rarr, lib, autoimport, fixup, chooser, seeded, timers, repair, timer, sockets, socket, shutdown, disabled, static, lxd_, _all, connectivity, dpkg, processing, var, cache, installation, subprocess, encountered, usr, bin,

Latest Articles

  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist