This tutorial gives a quick introduction to using the LXD UI.
It covers installing and initializing LXD, getting access to the UI, and carrying out some standard operations like creating, configuring, and interacting with instances, configuring storage, and using projects.
After going through these steps, you will have a general idea of how to use LXD through its UI, and you can start exploring more advanced use cases!
Note
Ensure that you have 20 GiB free disk space before starting this tutorial.
The easiest way to install LXD is to install the snap package.
If you prefer a different installation method, or use a Linux distribution that is not supported by the snap package, see How to install LXD.
Install snapd:
Run snapversion to find out if snap is installed on your system:
If you get an error message that the LXD snap is already installed, run the following command to refresh it and ensure that you are running an up-to-date version:
sudo snap refresh lxd
Check if the current user is part of the lxd group (the group was automatically created during the previous step):
getent group lxd | grep "$USER"
If this command returns a result, you’re set up correctly and can continue with the next step.
If there is no result, enter the following commands to add the current user to the lxd group (which is needed to grant the user permission to interact with LXD):
sudo usermod -aG lxd "$USER"
newgrp lxd
Enter the following command to initialize LXD:
lxd init --minimal
This will create a minimal setup with default options.
If you want to tune the initialization options, see How to initialize LXD for more information.
Expose LXD to the network by setting the core.https_address server configuration option:
lxc config set core.https_address :8443
Access the UI in your browser by entering the server address (for example, https://127.0.0.1:8443 for a local server, or an address like https://192.0.2.10:8443 for a server running on 192.0.2.10).
If you have not set up a secure TLS server certificate, LXD uses a self-signed certificate, which will cause a security warning in your browser.
Use your browser’s mechanism to continue despite the security warning.
Set up the certificates that are required for the UI client to authenticate with the LXD server by following the steps presented in the UI.
You have two options, depending on whether you already have a client certificate selected in your browser:
If you don’t have a certificate yet, click Create a new certificate to get instructions for creating a set of certificates, adding the public key to the server’s trust store, and adding the private key to your browser.
If you already have a client certificate in your browser, select “use an existing certificate” to authorize the certificate with the server and re-use it.
Let’s start by launching a few instances.
With instance, we mean either a container or a virtual machine.
See Containers and VMs for information about the difference between the two instance types.
Select Instances from the navigation.
Click Create instance to launch a container called first using the Ubuntu 24.04 LTS image:
To select the base image, click Browse images.
Click Select next to the Ubuntu 24.04 LTS image.
Note
The images that are displayed are hosted on pre-configured Remote image servers.
You can filter which images are displayed.
Launching this container takes a few seconds, because the image must be downloaded and unpacked first.
Create another container called second, using the same image.
After entering the name and selecting the image, click Create instead of Create and start.
This container will be created but not started.
Note
Creating this container is quicker than launching the first, because the image is already available locally.
Create and start a VM called ubuntu-vm using the Ubuntu 24.04 LTS image.
To create a VM instead of a container, select VM as the instance type:
Note
Even though you are using the same image name to launch the instance, LXD downloads a slightly different image that is compatible with VMs.
Start creating (do not click Create and start yet) a VM called ubuntu-desktop.
When selecting the image, filter by variant “desktop” to find the Ubuntu 24.04 LTS desktop image.
Note that after you select the image, the instance type is automatically set to VM:
To run smoothly, the desktop VM needs more RAM.
Therefore, navigate to Advanced > Resource limits and set the Memory limit to 4 GiB.
Then click Create and start to start the instance.
Check the list of instances that you created:
You will see that all but the second container are running.
This is because you created the second container but didn’t start it.
You can start the second container by clicking the Start button (▷) next to it.
In the list of instances, click on one of the lines to see more information about the respective instance:
Click on an instance name to go to the instance detail page, where you can inspect your instance:
The Overview tab shows general information and usage statistics about the instance.
The Configuration tab contains the instance configuration.
For now, just click through to inspect the configuration.
We’ll do some updates later.
If you want to see the full instance configuration, go to the YAML configuration:
The Snapshots tab shows available snapshots.
You can ignore this for now; we’ll look into snapshots later.
The Terminal tab allows you to interact with your instance.
For example, enter the following command to display information about the operating system:
When you navigate away from the Terminal tab, you are asked to confirm.
The reason for this confirmation prompt is that the terminal session is not saved, so once you navigate away, your command history is lost.
The Console tab is mainly relevant during startup of an instance, and for VMs.
Go to the instance detail page of the ubuntu-desktop VM and check the graphic console:
The Logs tab contains log files for inspection and download.
Running instances have only limited information.
More log files are added if an instance ends up in error state.
For the remainder of the tutorial, we don’t need all of the instances we created.
So let’s clean some of them up:
Go back to the instances list.
Stop the second container by clicking the Stop button (□) next to it.
Delete the second container.
To do so, click the instance name to go to the instance detail page.
Then click the Delete instance button at the top.
Go to the instance detail page of the ubuntu-vm VM to delete it.
You will see that the Delete instance button at the top is not active.
This is because the instance is still running.
Stop it by clicking the Stop button (□) at the top, then click Delete instance.
Tip
If stopping an instance takes a long time, click the spinning Stop button to go back to the confirmation prompt, where you can select to force-stop the instance.
There are several limits and configuration options that you can set for your instances.
See Instance options for an overview.
Let’s create another container with some resource limits:
On the instances list, click Create instance.
Enter limited as the instance name and select the Ubuntu 24.04 LTS image.
Expand Advanced and go to Resource limits.
Change the Exposed CPU limit to 1 and the Memory limit to 4 GiB:
Click Create and start.
When the instance is running, go to its instance detail page and select Configuration > Advanced > Resource limits.
Confirm that the limits you set are visible.
Go to the Terminal tab and enter the following commands:
free -m
nproc
You should see that the total memory is limited to 4096, and the number of available CPUs is 1.
Go to the instance detail page of the first container and enter the same commands.
You should see that the values differ from those of the limited container.
The exact values depend on your host system (so if your host system has only one CPU, for example, you might see one CPU for the first container as well).
You can also update the configuration while your container is running:
Go back to the instance detail page of the limited container and select Configuration > Advanced > Resource limits.
Click Edit instance and change the memory limit to 2 GiB.
Then save.
Go to the Terminal tab and enter the following command:
free -m
Note that the number has changed.
Depending on the instance type and the storage drivers that you use, there are more configuration options that you can specify.
For example, you can configure the size (quota) of the root disk device for a VM:
Go to the terminal for the ubuntu-desktop VM and check the current size of the root disk device (/dev/sda2):
df -h
Navigate to Configuration > Advanced > Disk devices.
Tip
By default, the size of the root disk is inherited from the default profile.
Profiles store a set of configuration options and can be applied to instances instead of specifying the configuration option for each instance separately.
You can add additional storage to your instance, and also share storage between different instances.
See Storage volumes for more information.
Let’s start by creating a custom storage volume:
Navigate to Storage > Volumes.
Even though you have not created any custom storage volumes yet, you should see several storage volumes in the list.
These are instance volumes (which contain the root disks of your instances) and image volumes (which contain the cached base images).
Click Createvolume and enter a name and a size.
Leave the default content type (filesystem).
After creating the instance, we can attach it to some instances:
Go to the instance detail page of the first container.
Go to Configuration > Advanced > Disk devices.
Click Edit instance and then Attach disk device.
Select the disk device that you just created.
Tip
You can create a custom volume directly from this screen as well.
Enter /data as the mount point and save your changes:
Go to the Terminal tab and enter the following command to create a file on the custom volume:
touch /data/hello_world
Go to the instance detail page of the ubuntu-desktop VM and add the same custom storage volume with the same mount point (/data).
Go to the Terminal tab and enter the following command to see the file you created from your first container:
ls /data/
Note
You can also look at the directory in the file browser.
To do so, enter the following command in the terminal first:
chown ubuntu /data /data/*
Then switch to the console, open the file browser, and navigate to the /data folder:
Originally, there is only a default project on the server.
All the instances you created so far are part of this project.
Now, let’s create another project:
Expand the Project dropdown and click Create project:
Enter tutorial as the project name.
For features, select Customised.
You can then select which features should be isolated.
“Isolated” in this context means that if you select one of the features, entities of this type are confined to the project.
So when you use a project where, for example, storage volumes are isolated, you can see only the storage volumes that are defined within the project.
Deselect Storagevolumes and create the project.
The new project is automatically selected for you.
Let’s check its content:
Go to Instances.
You will see that there are no instances in your project, because instances are always isolated, and the instances you created earlier are in the default project.
Create an instance in the new project.
You should notice that you get an error about missing root storage.
The reason for this is that the root storage is usually defined in the default profile, but profiles are isolated in the project.
To resolve the error, edit the root storage.
Use the default pool and leave the size empty.
Then create the instance.
Go to Storage > Volumes.
Remember that in the default project, you saw three different kinds of storage volumes in the volume list:
Instance (container or VM) volumes
Image volumes
Custom volumes
You should see the same three types in the tutorial project.
However, note the following:
You can see only one instance volume and one image volume.
These are for the one instance you created in the tutorial project.
You cannot see the instance and image volumes for the instances you created in the default project, because both instances and images are isolated in the tutorial project, so you cannot see the corresponding storage volumes from other projects.
You can see the custom storage volume that you created in the default project.
Because you deselected Storagevolumes when creating the project, storage volumes are not isolated, and you can therefore see storage volumes from other projects.
Now that we’ve run through the basic functionality of LXD, let’s clean up the entities we created throughout the tutorial.
With the tutorial project still selected, go to the instances list and stop and delete the instance you created in this project.
Go to Images and click the Delete button () next to it.
Go to Configuration and click the Delete project button in the top-right corner.
After deleting the project, you are automatically switched back to the default project.
Stop and delete all instances in the default project.
To do this all at once, go to the instance list and select all instances.
Then click Stop at the top.
Finally, click Delete at the top.
Go to Storage > Volumes and click the Delete button () next to the tutorial_volume storage volume.
Note
Optionally, you can also delete the images that you used.
However, this isn’t really needed.
If you keep them, they will eventually expire (by default, when they haven’t been used for ten days).
Now that you’ve done your first experiments with LXD, you should read up on important concepts in the Explanation section and check out the How-to guides to start working with LXD!