Install LXC/LXD – Ubuntu Focal 20.04

This is an instruction to install LXC/LXD on Ubuntu and run the basic commands.

  • Distribution: Ubuntu Focal 20.04

Install Packages

user1:~$ sudo su -
root:~# apt update
root:~# apt upgrade

root:~# apt install lxd lxd-client

Initialize LXD

  • Accept all defaults except IP v6 (no IP v6)
root:~# lxd init

Launch a Container

root:~# lxc list
To start your first container, try: lxc launch ubuntu:22.04
Or for a virtual machine: lxc launch ubuntu:22.04 --vm

+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+

root:~# lxc launch images:alpine/3.16 my-alpine
Creating my-alpine
Starting my-alpine

root:~# lxc list
+-----------+---------+---------------------+------+------------+-----------+
|   NAME    |  STATE  |        IPV4         | IPV6 |    TYPE    | SNAPSHOTS |
+-----------+---------+---------------------+------+------------+-----------+
| my-alpine | RUNNING | 10.78.38.247 (eth0) |      | PERSISTENT | 0         |
+-----------+---------+---------------------+------+------------+-----------+


Clean up

root:~# lxc stop my-alpine

root:~# lxc delete my-alpine

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s