I have a Docker container based on an Ubuntu 20.04 image. In this Docker container, I want to open a Qt GUI. As host, I am using Windows 10.
When having a Linux machine as host, this setup is well discussed. For a Windows host however, this is not the case.
After finding this website, I tried to start the container with the following command:
docker run --rm -it -e DISPLAY=host.docker.internal:0.0 mydockerimage:latest
However, trying to run a Qt GUI results in the well known error
qt.qpa.xcb: could not connect to display host.docker.internal:0.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Aborted
After some research I noticed that the environment variable QT_X11_NO_MITSHM=1 is required. So i changed the run command:
docker run --rm -it -e DISPLAY=host.docker.internal:0.0 -e QT_X11_NO_MITSHM=1 mydockerimage:latest
Strangely, all Qt GUIs worked just fine ... for some time. Out of nowhere, the above error started occuring again. I don't know what changed, but until know, I didn't manage to get it working again.
So it seems, that it is possible to run a Qt GUI in a Ubuntu Docker on Windows. But I seem to miss something as I can't manage to make it reliably work.
Does someone has a clue what's happening, an how to get the GUI applications run again?