Linux Desktop Environments in an Incus Container

Normally Incus containers do not have a desktop GUI. In this tutorial I show how you can add a variety of desktop GUI environments to an incus container. Since incus containers share the kernel of the system running the incus server, incus containers require less overhead and fewer resources than a virtual machine.

In this tutorial I show how to install many Linux Desktop Environments on an Incus container running Ubuntu 24.04. The environments we configure are Cinnamon, Mate, Gnome, KDE, XFCE, LXDE and LXQT.

Let’s start out by creating an Ubuntu 24.04 container instance. If you haven’t watched my tutorial entitled Incus Containers Step by Step this tutorial relies on the “bridgeprofile” created in that presentation.

An Incus container is more like a Linux server because containers normally do not have a desktop GUI interface. We are going to show how to add various desktop environments to an an incus container.

Start by creating the container instance.

incus launch images:ubuntu/24.04 Test -c boot.autostart=true -p default -p bridgeprofile

Connect to the shell of the new container and take all of the upgrades.

incus shell Test
apt update && apt upgrade -y

Add yourself a user account on the container and grant it sudo privilege .

adduser scott
usermod -aG sudo scott

Move over to the new account.

su - scott

Install the dependencies for this exercise.

sudo apt install tasksel nano net-tools openssh-server xrdp xorgxrdp

The most important of these dependencies is “tasksel” which allows us to install the various desktop environments. I chose to install the “X” components to support X11 rather than Wayland and that’s just a personal choice.

I discovered that it was necessary to change the protections of the RDP certificate file and keys. I also had to change the ownership of the XRDP key file to be owned by the xrdp user.

sudo chmod 644 /etc/xrdp/cert.pem
sudo chmod 640 /etc/xrdp/key.pem
sudo chown :xrdp /etc/xrdp/key.pem

Now restart the xrdp service.

sudo systemctl restart xrdp

Run tasksel to choose the desktop environments to install.

sudo tasksel

Note that above I installed the Debian, Gnome, Xfce, KDE Plasma, Cinnamon, MATE, LXDE, and LXQt desktop environments for this tutorial. In reality, you will probably only want to install the environment that you want to use. Installing all of these desktop environments takes a lot of time and more storage space.

During the course of the installation, you will be prompted for which display manager you want. A display manager in Linux provides the graphical interface for the X11 login. I chose “gdm3”.

Now that all the the desktop environments are installed, execute the following command to choose your desktop environment.

sudo update-alternatives --config x-session-manager 

I chose number “1” to install the Cinnamon desktop which is the desktop environment that Linux Mint uses.

Before xrdp will operate properly, I need to edit the startwm script.

sudo nano /etc/xrdp/startwm.sh

Insert the following three lines before the “test” line in the script as shown.

unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
 . $HOME/.profile

Save the file out with a CTRL O and Enter and a CTRL X to exit the nano editor.

Now exit the container back to your Linux desktop computer.

exit
exit

image

Install the xfreerdp client on your desktop.

sudo apt install freerdp2-x11

Windows desktop users should be able to use the Windows RDP desktop to connect to the container also.

I used the “incus list” command on my incus server to find out the address of my Test container.

incus list

image

I used the xfreerdp command as follows to log into my container in fullscreen mode.

xfreerdp /u:scott /v:172.16.1.231 /f

The login screen appears as below.

After entering my password, I have the Cinnamon desktop from the incus container.

After logging out, I am returned to my desktop from where I executed the xfreerdp command. In order to select another desktop, I connect back to the container and execute the update-alternatives command to select a different desktop.

incus shell Test
update-alternatives --config x-session-manager 

This time I select the “MATE” environment.

Then I exit the container back to my Linux desktop and execute the xfreerdp command again.

exit
xfreerdp /u:scott /v:172.16.1.231 /f

After entering my password, I am on the MATE desktop in the Test container.

I log out of the MATE desktop. At the terminal, I go back into the container again and invoke the update-alternative program.

incus shell Test
update-alternatives --config x-session-manager 

Now I switch to the Gnome desktop.

Exit the container and run xfreerdp to connect again.

exit
xfreerdp /u:scott /v:172.16.1.231 /f

After providing my password, I am at the Gnome desktop.

I log out of the Gnome desktop. At the terminal, I go back into the container again and invoke the update-alternative program.

incus shell Test
update-alternatives --config x-session-manager 

Now I switch to the XFCE desktop.

Exit the container and run xfreerdp to connect again.

exit
xfreerdp /u:scott /v:172.16.1.231 /f

After providing my password, I am at the XFCE desktop.

I log out of the XFCE desktop. At the terminal, I go back into the container again and invoke the update-alternative program.

incus shell Test
update-alternatives --config x-session-manager 

Now I switch to the LXDE desktop.

Exit the container and run xfreerdp to connect again.

exit
xfreerdp /u:scott /v:172.16.1.231 /f

After providing my password, I am at the LXDE desktop.

I log out of the LXDE desktop. At the terminal, I go back into the container again and invoke the update-alternative program.

incus shell Test
update-alternatives --config x-session-manager 

Now I switch to the KDE Plasma desktop.

Exit the container and run xfreerdp to connect again.

exit
xfreerdp /u:scott /v:172.16.1.231 /f

After providing my password, I am at the KDE Plasma desktop.

I log out of the KDE Plasma desktop. At the terminal, I go back into the container again and invoke the update-alternative program.

incus shell Test
update-alternatives --config x-session-manager 

Now I switch to the LXQT desktop.

Exit the container and run xfreerdp to connect again.

exit
xfreerdp /u:scott /v:172.16.1.231 /f

After providing my password, I am at the LXQT desktop.

As you have seen here, it is possible to install desktop environments on incus containers and switch between them easily.

You can install the default Ubuntu desktop also:

sudo apt install ubuntu-desktop

I was using an Ubuntu 24.04 container and unfortunately this newer version does not yet support the deepin or elementary-OS (Pantheon) desktops.

If you are running Ubuntu 22.04, you can add the Deepin desktop environment as follows:

sudo add-apt-repository ppa:ubuntudde-dev/stable
sudo apt install ubuntudde-dde

You can also install Pantheon on 22.04:

sudo add-apt-repository ppa:elementary-os/stable
sudo apt install elementary-desktop

The xfreerdp program can also be run in a windowed mode with the ability to resize:

xfreerdp /u:scott /v:172.16.1.231 /dynamic-resolution