Launching desktop instances on incus

Incus is a great tool for managing virtual machines and vm-like containers, but how to get a full desktop environment into one isn't exactly intuitive. Since there is no direct way to achieve this, an RDP environment has to be set up manually.

Creating a base machine

We need a base machine to work with. This example will use debian 13 running as a container, but you can pick any other incus image or use a vm instead (just make sure to adjust installable package names).


Start by launching a debian 13 container:

sudo incus launch images:debian/13 mydesktop

If you want a virtual machine instead, simply add --vm at the end.

Next, start a shell into the machine:

sudo incus exec mydesktop -- bash

Now inside the machine, install and start common RDP dependencies:

apt update
apt install \
  xrdp \
  dbus-x11 \
  x11-xserver-utils \
  sudo
systemctl enable xrdp
systemctl start xrdp

You may have noticed that we are installing X11 instead of wayland dependencies here. While modern desktop environments are slowly moving from X11 to wayland, remote desktop (RDP) utilities haven't quite caught up with the shift, so X11 remains the only reliable choice for now.


Next, create a user inside the incus container:

adduser myuser # will prompt for password
usermod -aG sudo myuser # optionally add new user to sudo group

As a last optional step, you can enable GPU acceleration for the container by adding a gpu device from the host:

sudo incus config device add mydesktop gpu gpu

Note this does not affect RDP directly, but OpenGL apps run on the container will benefit.


And install mesa-utils inside the container:

apt install mesa-utils

With that out of the way, we can choose a desktop environment.

Installing a desktop environment

There are many options to choose from here, but the most popular ones are xfce4 for minimal resource usage (<400mb ram), kde for a lightweight fully featured desktop (~800mb ram) and gnome as the heavier default desktop experience (>1.2gb ram) for most modern distros. Pick one and follow the installation instructions below:


XFCE4

apt install xfce4 xfce4-goodies
echo xfce4-session > /home/myuser/.xsession
chown myuser:myuser /home/myuser/.xsession

KDE

apt install kde-standard
echo startplasma-x11 > /home/myuser/.xsession
chown myuser:myuser /home/myuser/.xsession

You can instead install kde-plasma for a minimal KDE setup or kde-full for a complete one including optional tools.


Gnome

apt install gnome
echo gnome-session > /home/myuser/.xsession
chown myuser:myuser /home/myuser/.xsession

Alternatively, install gnome-core for a minimal installation.

Connecting to the machine

To connect over RDP, you will need the IP address of the container or vm:

sudo incus list -c 4 mydesktop

The output will show something like

+--------------------+
|        IPV4        |
+--------------------+
| 10.98.76.70 (eth0) |
+--------------------+

Your IP will likely differ, note it for the next step.

Lastly, you need an RDP client. Remmina is a great choice for an open source RDP client that is available in most linux package repositories by default.

The connection process is fairly straight forward from here: connect to the container's IP, put in the name and password of the user created earlier and accept the certificate when prompted.


That completes the base setup. A production setup should extend this with common precautions like securing RDP port 3389 or tunneling over SSH, making IPs static etc - but that's beyond the scope of this article.

More articles

Sorting email inboxes with local LLMs

Categorizing by message contents without sacrificing privacy

Styling terminal output

Controlling terminal contents with escape sequences

The complete guide to C strings

Including common problems and solutions