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

  • Proxmox How To Custom Partition During Install
  • Hyper-V Linux VM Boots to Black Screen, Storage, NIC Not Found Issues
  • Ubuntu Mint How to Fix Missing/Broken /dev and /dev/pts which causes terminal to immediately close exit and not work
  • How high can a Xeon CPU get?
  • bash fix PATH environment variable "command not found" solution
  • Ubuntu Linux Mint Debian Redhat Youtube Cannot Play HD or 4K videos, dropped frames or high CPU usage with Nvidia or AMD Driver
  • hostapd example configuration for high speed AC on 5GHz using WPA2
  • hostapd how to enable and use WPS to connect wireless devices like printers
  • Dell Server Workstation iDRAC Dead after Firmware Update Solution R720, R320, R730
  • Cloned VM/Server/Computer in Linux won't boot and goes to initramfs busybox Solution
  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease