VNC Linux Desktop for amd64/arm64 in a Container


Running a light VNC Linux Desktop on docker on a regular desktop or on a small arm board may be of help in some cases. I recently needed it once again, and I therefore took some time to create a docker image for it. You can find it in Docker Hub if you need it.

https://hub.docker.com/r/carlonluca/vnc-desktop
https://github.com/carlonluca/docker-vnc-desktop

It happens sometimes that I need a clean environment to work on a specific task. The usual thing I do is to spin a docker container or a complete desktop on a virtual machine. The virtual machine is not a good solution for its slow performance. The docker container is much better, but sometimes a complete desktop environment may be handy.

I tried a few solutions around, and these seemed good at first:

x11docker is an advanced solution to the problem. It works and it has a considerable amount of options. The other two solutions worked in some cases and failed in others.

In all cases though, I found some things on my way and I therefore preferred to create my own simple desktop. I therefore wrote a basic Dockerfile, simpler than the projects listed above: https://hub.docker.com/r/carlonluca/vnc-desktop.

This image does not include noVNC, but only the regular VNC to be used with a desktop VNC client. It includes images for LXQT and XFCE, and for both the arm64 architecture and the amd64 architecture. This made it possible for me to also run it on my Raspberry Pi 4 with Ubuntu 64 bit installed (the same Pi running thi blog by the way 😃). This is the desktop I can get on the Pi:

I tried also XFCE, but it seems it requires a bit too much RAM for that Pi (it already has a lot of running services). The result may be different on a dedicated Pi. However, on the desktop, XFCE works very well.

At the moment this is pretty much what I need. However, a more performant solution would be to make the desktop connect to the host using Xephyr, but that is something I did not implement yet (should be simple to add though).

Run

The most important thing for me is that it is simple and quick to run the container, cause I typically need it for small tasks. So this is how you can run it:

docker run --rm \
    -e USER=luca -e RESOLUTION=1920x1080 \
    -p 5900:5900 \
    carlonluca/vnc-desktop:bullseye-xfce

The env variables are optional:

  • USER: the name of the user running the DE (root is used if omitted);
  • RESOLUTION: the size of the screen (wxh).

You can find the scripts to build the images here: https://github.com/carlonluca/docker-vnc-desktop.

Browser

It may be bothering to install a browser cause Firefox on Ubuntu is supposed to run as a snap package. Snap packages do not run in docker unless a specific setup is created. To have a browser, use the Debian image and install firefox-esr, or use the Google Chrome ppa repo.

Leave a Reply

Your email address will not be published. Required fields are marked *