Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI Qt Application in a docker container

Tags:

docker

qt

I try to run some Qt application in a docker container by mounting /tmp/.X11-unix. I saw here that can be difficult.

So when I run kdevelop in a docker container, it does not work (I get an empty window). But if I run qtcreator it's fine.

I think the difference is because of the Qt version used (kdevelop is developed with Qt4 and qtcreator with Qt5). All my other Qt5 applications work fine, but not a single Qt4 application.

Question:

Does anyone know what to do to launch a Qt4 application, without going a long way round like with vnc or ssh, just like this:

docker run -it -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix someQt4AppContainer

?

like image 919
jmc Avatar asked Jan 27 '16 14:01

jmc


People also ask

How do I run a GUI application in a Docker container?

To run a new docker container from your created os image in which you already install some GUI applications and env displays the environment that it received from its parent(base os), and set image name and version as you mentioned in the previous command.

Can Docker be used for GUI applications?

GUI through Docker is crucial for numerous applications. However, several steps are required to be able to view the GUI at the host machine. In this article, we will use Tkinter to create a simple GUI in Python which can be accessed through Docker.

Can Docker run Windows GUI applications?

The short answer here is no. Windows containers don't have the underlying GUI components available, so you can't run any desktop application on Windows containers.

Can a container have a GUI?

The container we launched now has the capability to run GUI applications. But we can only run two GUI applications (i.e. firefox and gedit) in our container because we've installed these two applications only. Launching the container (OS).


1 Answers

Qt5 and Qt4 has a different rendering subsystems

Qt4 renderer just needs a hint:

export QT_GRAPHICSSYSTEM="native"

This must be work

QT_GRAPHICSSYSTEM="native" docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix someQt4AppContainer
like image 196
Vladislav Mikitich Avatar answered Sep 21 '22 18:09

Vladislav Mikitich