Getting started with the UI

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.

Install and initialize LXD

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.

  1. Install snapd:

    1. Run snap version to find out if snap is installed on your system:

      user@host:~$ snap version
      snap    2.63+24.04ubuntu0.1snapd   2.63+24.04ubuntu0.1series  16ubuntu  24.04kernel  5.15.0-117-generic

      If you see a table of version numbers, snap is installed and you can continue with the next step of installing LXD.

    2. If the command returns an error, run the following commands to install the latest version of snapd on Ubuntu:

      sudo apt update
      sudo apt install snapd
      

      Note

      For other Linux distributions, see the installation instructions in the Snapcraft documentation.

  2. Enter the following command to install LXD:

    sudo snap install lxd
    

    If you get an error message that the 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
    
  3. 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
    
  4. 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.

Access the UI

You access the LXD UI through your browser. See How to access the LXD web UI for more information.

  1. Expose LXD to the network by setting the core.https_address server configuration option:

    lxc config set core.https_address :8443
    
  1. 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.

    Example for a security warning in Chrome
  2. 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.

      Instructions for setting up certificates for the UI
    • 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.

      Instructions for re-using an existing certificate for the UI

    See Remote API authentication for more information.

Create and start instances

Let’s start by launching a few instances. With instance, we mean either a container or a virtual machine. See About containers and VMs for information about the difference between the two instance types.

  1. Select Instances from the navigation.

  2. Click Create instance to launch a container called first using the Ubuntu 24.04 LTS image:

    Create an Ubuntu 24.04 LTS container

    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.

    You can also upload a custom ISO file to boot from. See Create a VM that boots from an ISO for more information.

  3. To launch the container, click Create and start.

    Note

    Launching this container takes a few seconds, because the image must be downloaded and unpacked first.

  4. 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.

  5. 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:

    Create an Ubuntu 24.04 LTS VM

    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.

  6. 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:

    Create an Ubuntu 24.04 LTS desktop 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.

  7. Check the list of instances that you created:

    List of instances

    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.

See How to create instances for more information.

Inspect instances

In the list of instances, click on one of the lines to see more information about the respective instance:

Information about an instance in the instance summary

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:

    YAML configuration of an instance
  • 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:

    cat /etc/*release
    

    Or have some fun:

    apt update
    apt install fortune
    /usr/games/fortune
    

    See Get shell access to your instance for more information.

    Note

    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:

    Graphic console of the Ubuntu desktop VM

    See How to access the console for more information.

  • 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.

    See How to troubleshoot failing instances for more information.

Stop and delete instances

For the remainder of the tutorial, we don’t need all of the instances we created. So let’s clean some of them up:

  1. Go back to the instances list.

  2. Stop the second container by clicking the Stop button (□) next to it.

  3. 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.

  4. 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.

See How to manage instances for more information.

Configure instances

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:

  1. On the instances list, click Create instance. Enter limited as the instance name and select the Ubuntu 24.04 LTS image.

  2. Expand Advanced and go to Resource limits.

  3. Change the Exposed CPU limit to 1 and the Memory limit to 4 GiB:

    Configure some resource limits
  4. Click Create and start.

  5. 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.

  6. 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.

  7. 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).

  8. You can also update the configuration while your container is running:

    1. Go back to the instance detail page of the limited container and select Configuration > Advanced > Resource limits.

    2. Click Edit instance and change the memory limit to 2 GiB. Then save.

    3. 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 of the root disk device for a VM:

  1. Go to the terminal for the ubuntu-desktop VM and check the current size of the root disk device (/dev/sda2):

    df -h
    
  2. 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.

    See How to use profiles for more information.

  3. Override the size of the root disk device to be 30 GiB:

    Change the size of the root disk
  4. Save the configuration, and then restart the VM by clicking the Restart button ().

  5. In the terminal, check the size of the root disk device again:

    df -h
    

    Note that the size has changed.

See How to configure instances and Instance configuration for more information.

Manage snapshots

You can create a snapshot of your instance, which makes it easy to restore the instance to a previous state.

  1. Go to the instance detail page of the first container and select the Snapshots tab.

  2. Click Create snapshot and enter the snapshot name clean. Leave the other options unchanged and create the snapshot.

    You should now see the snapshot in the list.

  3. Go to the Terminal tab and break the container:

    rm /usr/bin/bash
    
  4. Confirm the breakage by reloading the page:

    Error when trying to load the terminal

    The UI cannot open a terminal in your container anymore, because you deleted the bash command.

  5. Go back to the Snapshots tab and restore the container to the state of the snapshot by clicking the Restore snapshot button () next to it.

  6. Go back to the Terminal tab. The terminal should now load again.

  7. Go to the Snapshots tab and delete the snapshot by clicking the Delete snapshot button () next to it.

See Use snapshots for instance backup for more information.

Add a custom storage volume

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:

  1. 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).

  2. Click Create volume and enter a name and a size. Leave the default content type (filesystem).

After creating the instance, we can attach it to some instances:

  1. Go to the instance detail page of the first container.

  2. Go to Configuration > Advanced > Disk devices.

  3. Click Edit instance and then Attach disk device.

  4. Select the disk device that you just created.

    Tip

    You can create a custom volume directly from this screen as well.

  5. Enter /data as the mount point and save your changes:

    Add the custom volume to your instance
  6. Go to the Terminal tab and enter the following command to create a file on the custom volume:

    touch /data/hello_world
    
  7. Go to the instance detail page of the ubuntu-desktop VM and add the same custom storage volume with the same mount point (/data).

  8. 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:

    View the file on the shared volume in the file browser

Use projects

You can use projects to group related instances, and other entities, on your LXD server. See About projects and How to create and configure projects for more information.

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:

  1. Expand the Project dropdown and click Create project:

    Create a project
  2. Enter tutorial as the project name.

  3. 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.

  4. Deselect Storage volumes and create the project.

The new project is automatically selected for you. Let’s check its content:

  1. 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.

  2. 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.

  3. To resolve the error, edit the root storage. Use the default pool and leave the size empty.

    Then create the instance.

  4. 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 Storage volumes when creating the project, storage volumes are not isolated, and you can therefore see storage volumes from other projects.

Clean up entities

Now that we’ve run through the basic functionality of LXD, let’s clean up the entities we created throughout the tutorial.

  1. With the tutorial project still selected, go to the instances list and stop and delete the instance you created in this project.

  2. Go to Images and click the Delete button () next to it.

  3. 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.

  4. 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.

  5. 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).

Next steps

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!