Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Run Qt GUI application inside docker.
QtWS25 Last Chance

Run Qt GUI application inside docker.

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 23.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dariusz.o
    wrote on 28 Oct 2020, 09:49 last edited by dariusz.o
    #1

    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 !

    1 Reply Last reply
    0
    • D Offline
      D Offline
      devjb
      wrote on 28 Oct 2020, 10:05 last edited by
      #2

      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

      D 1 Reply Last reply 28 Oct 2020, 10:19
      0
      • D devjb
        28 Oct 2020, 10:05

        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

        D Offline
        D Offline
        dariusz.o
        wrote on 28 Oct 2020, 10:19 last edited by dariusz.o
        #3

        @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 !

        P 1 Reply Last reply 28 Oct 2020, 12:33
        0
        • D dariusz.o
          28 Oct 2020, 10:19

          @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 !

          P Offline
          P Offline
          Pablo J. Rogina
          wrote on 28 Oct 2020, 12:33 last edited by
          #4

          @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.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          D 1 Reply Last reply 28 Oct 2020, 12:48
          0
          • P Pablo J. Rogina
            28 Oct 2020, 12:33

            @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.

            D Offline
            D Offline
            dariusz.o
            wrote on 28 Oct 2020, 12:48 last edited by
            #5

            @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.

            P 1 Reply Last reply 28 Oct 2020, 13:44
            0
            • D dariusz.o
              28 Oct 2020, 12:48

              @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.

              P Offline
              P Offline
              Pablo J. Rogina
              wrote on 28 Oct 2020, 13:44 last edited by
              #6

              @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

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              D 1 Reply Last reply 28 Oct 2020, 14:06
              0
              • P Pablo J. Rogina
                28 Oct 2020, 13:44

                @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

                D Offline
                D Offline
                dariusz.o
                wrote on 28 Oct 2020, 14:06 last edited by
                #7

                @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.

                P 1 Reply Last reply 28 Oct 2020, 14:40
                0
                • D dariusz.o
                  28 Oct 2020, 14:06

                  @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.

                  P Offline
                  P Offline
                  Pablo J. Rogina
                  wrote on 28 Oct 2020, 14:40 last edited by
                  #8

                  @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

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  D 1 Reply Last reply 28 Oct 2020, 17:29
                  1
                  • M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 28 Oct 2020, 15:16 last edited by
                    #9

                    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"

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dariusz.o
                      wrote on 28 Oct 2020, 16:50 last edited by dariusz.o
                      #10

                      @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.

                      1 Reply Last reply
                      0
                      • P Pablo J. Rogina
                        28 Oct 2020, 14:40

                        @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

                        D Offline
                        D Offline
                        dariusz.o
                        wrote on 28 Oct 2020, 17:29 last edited by
                        #11

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

                        P 1 Reply Last reply 28 Oct 2020, 17:31
                        0
                        • D dariusz.o
                          28 Oct 2020, 17:29

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

                          P Offline
                          P Offline
                          Pablo J. Rogina
                          wrote on 28 Oct 2020, 17:31 last edited by
                          #12

                          @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...

                          Upvote the answer(s) that helped you solve the issue
                          Use "Topic Tools" button to mark your post as Solved
                          Add screenshots via postimage.org
                          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            dariusz.o
                            wrote on 30 Oct 2020, 14:47 last edited by
                            #13

                            @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!

                            1 Reply Last reply
                            3

                            9/13

                            28 Oct 2020, 15:16

                            • Login

                            • Login or register to search.
                            9 out of 13
                            • First post
                              9/13
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved