Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Run Qt GUI application inside docker.



  • Hi,
    What I'm trying to achieve is to run QtApp inside docker, this app uses OpenGL inside, so I need to have a X server installed (to create OpenGL context) on my docker image, please correct my if I'm wrong.

    What is important in this case - I can't provide X11 socket as volume from host, cuz final host won't have GPU and X at all. I don't need any preview of my app during its work, this app have to do something with OpenGL in offscreen mode. I just need images that was created by this app.

    I'm using Ubuntu 16.04, I have already installed X, and MESA drivers.

    • sudo apt-get install -y xserver-xorg xinit
    • sudo apt-get install -y mesa-utils libegl1-mesa libegl1-mesa-dev libgbm-dev libgbm1 libgl1-mesa-dev libgl1-mesa-dri libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev

    When I'm trying to run my app, I have this message:

    loaded library "/home/user/app/platforms/libqxcb.so"
    qt.qpa.xcb: could not connect to display
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    

    I assume that I need to simulate that I have fake display connected. AFAIK I need to do that in /etc/X11/xorg.conf file.
    I tried to generate this file with sudo Xorg -configure, but I'm getting this message:

    X.Org X Server 1.18.4
    Release Date: 2016-07-19
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 4.15.0-115-generic x86_64 Ubuntu
    Current Operating System: Linux 12e353007a6b 4.19.76-linuxkit #1 SMP Thu Oct 17 19:31:58 UTC 2019 x86_64
    Kernel command line: BOOT_IMAGE=/boot/kernel console=ttyS0 console=ttyS1 page_poison=1 vsyscall=emulate panic=1 root=/dev/sr0 text
    Build Date: 04 September 2020  03:38:30PM
    xorg-server 2:1.18.4-0ubuntu0.10 (For technical support please see http://www.ubuntu.com/support)
    Current version of pixman: 0.33.6
    	Before reporting problems, check http://wiki.x.org
    	to make sure that you have the latest version.
    Markers: (--) probed, (**) from config file, (==) default setting,
    	(++) from command line, (!!) notice, (II) informational,
    	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: "/var/log/Xorg.0.log", Time: Wed Oct 28 09:44:27 2020
    List of video drivers:
    	modesetting
    xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)
    No devices to configure.  Configuration failed.
    (EE) Server terminated with error (2). Closing log file.
    

    Could you tell me what I'm doing wrong, what others step do I need to take to achieve this goal and run my app inside docker.

    Thanks a lot for you help !



  • I personally did never run a gui application in docker yet. However, I know that you should pass your DISPLAY-Environment variable to docker with -e and as well provide your X11 socket as a shared volume using -v. You will find tutorials around which show how to do so.

    For example (I did not read this article and cannot say whether its content will or will not help) https://medium.com/@SaravSun/running-gui-applications-inside-docker-containers-83d65c0db110



  • @devjb I know this possibility, but it won't work for me. I need to run my X server inside docker, I can't provide X11 socket as volume from host, cuz final host won't have GPU and X at all.
    What I didn't say earlier is that I don't need any preview, this app have to do something with OpenGL in offscreen mode. I just need images that was created by this app. Byt thanks for your reply !



  • @dariusz-o said in Run Qt GUI application inside docker.:

    final host won't have GPU

    Just curious how you expect to have an X server running inside the Docker container if the host won't provide a graphical device...

    No devices to configure. Configuration failed.



  • @Pablo-J-Rogina I think that it's possible to tell X server that there is fake monitor connected and for OpenGL usage I can use CPU through MESA drivers. I'm not 100% sure if it possible and if I understand it well. But just for now it seems legit for me.



  • @dariusz-o said in Run Qt GUI application inside docker.:

    this app have to do something with OpenGL in offscreen mode.

    Not sure why X server ended up being considered, when you goal is offscreen OpenGL.
    Anyway, I guess you may want to consider QOffscreenSurface



  • @Pablo-J-Rogina This app I want to run won't work without X, X are needed to create OpenGL context. In this case I have to adjust environment to app, not app to environment.



  • @dariusz-o said in Run Qt GUI application inside docker.:

    X are needed to create OpenGL context

    Not much expertise with graphic backends (X, OpenGL) but I do run Qt apps on RPi devices using fullscreen EGL without X server at all...

    So again, IMO it looks like your X server requirement seems at odds with the OpenGL requirement at some extent


  • Lifetime Qt Champion

    hi
    What version of Qt do you use ?
    After upgrading from 5.9 to 5.15 in Linux Mint
    i had to do
    sudo apt-get install --reinstall libxcb-xinerama0
    to fix the error
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    when i tried to run Creator but not sure its the same as I didnt get
    "qt.qpa.xcb: could not connect to display"



  • @mrjj I'm using Qt 5.12.2
    I managed how to connect fake display with Xvfb :1 -screen 0 1024x768x16 .
    This display works cuz I launched glxgears and I made screenshot with ImageMagick (gears were visable on it).

    After I connected this virtual display I don't get "qt.qpa.xcb: could not connect to display" anymore. So I'm one step closer.

    Now I'getting info like this

    Got keys from plugin meta data ("xcb")
    loaded library "/home/user/app/platforms/libqxcb.so"
    loaded library "Xcursor"
    QFactoryLoader::QFactoryLoader() checking directory path "/home/user/app/platformthemes" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/home/user/app/platforminputcontexts" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/home/user/app/styles"
    

    I got all those catalogs at /opt/Qt/5.12.2/gcc_64/plugins/ and I added this path to LD_LIBRARY_PATH I'm not sure why it suggests me that those catalogs are missed.



  • @Pablo-J-Rogina But do your apps on RPi use OpenGL context, shaders, etc. ?



  • @dariusz-o said in Run Qt GUI application inside docker.:

    But do your apps on RPi use OpenGL context, shaders, etc. ?

    I really don't know...



  • @Pablo-J-Rogina @mrjj

    Ok, setting virtual display with Xvfb :1 -screen 0 1024x768x16 & and setting variables:

    ENV QT_DEBUG_PLUGINS=1
    ENV QT_QPA_PLATFORM=xcb
    ENV QT_QPA_PLATFORM_PLUGIN_PATH=/opt/Qt/${QT_VERSION}/gcc_64/plugins
    ENV QT_PLUGIN_PATH=/opt/Qt/${QT_VERSION}/gcc_64/plugins
    ENV DISPLAY=:1
    

    solved everything!
    It finally works ! :)

    Thanks for yours interest!


Log in to reply