LinuxMint 19: Install LXD for container

Table of Contents

1 Install LXD

Install these packages for LXD.

$ sudo apt install -y -o ‘apt::install-recommends=true’ lxd lxd-client lxd-tools criu

Install this package if you use ZFS.

$ sudo apt install -y zfsutils-linux

Wait LXD daemon starting.

$ sudo lxd waitready

Initialize LXD with the following command.

$ sudo lxd initWould you like to use LXD clustering? (yes/no) [default=no]: noDo you want to configure a new storage pool? (yes/no) [default=yes]:yesName of the new storage pool [default=default]: defaultName of the storage backend to use (dir, lvm, zfs) [default=zfs]: dirWould you like to connect to a MAAS server? (yes/no) [default=no]: noWould you like to create a new network bridge? (yes/no) [default=yes]:yesWhat should the new bridge be called? [default=lxdbr0]: lxdbr0What IPv4 address should be used? (CIDR subnet notation, “auto” or“none”) [default=auto]: autoWhat IPv6 address should be used? (CIDR subnet notation, “auto” or“none”) [default=auto]: noneWould you like LXD to be available over the network? (yes/no)[default=no]: noWould you like stale cached images to be updated automatically?(yes/no) [default=yes] yesWould you like a YAML “lxd init” preseed to be printed? (yes/no)[default=no]: no

You can use pipe for automatic initialization.

$ cat <<EOF | sudo lxd initnoyesdefaultdirnoyeslxdbr0autononenoyesnoEOF

The users in lxd group can run lxd without sudo command. After adding user to lxd group, restart machine.

$ sudo gpasswd -a “${USER}” lxd$ sudo reboot

2 Run container

“lxc launch” is combined with “lxc init” and “lxc start”. “lxc exec” runs command on container.

$ lxc launch images:debian/stretch debian<snip>$ lxc exec debian ip a s1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWNgroup default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever5:eth0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueuestate UP group default qlen 1000 link/ether 00:16:3e:3c:1d:23 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet brd scope global eth0 valid_lft forever preferred_lft forever inet6 fd42:6bb1:545e:554b:216:3eff:fe3c:1d23/64 scope globalmngtmpaddr dynamic valid_lft 3596sec preferred_lft 3596sec inet6 fe80::216:3eff:fe3c:1d23/64 scope link valid_lft forever preferred_lft forever

“lxc launch” is equal with the following “lxc init” and “lxc start”. “lxc init” creates container. “lxc start” starts container.

$ lxc init images:debian/stretch debian$ lxc start debian$ lxc exec debian ip a s

Android | Linux | SDL - Narrow Escape