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. Failed to run Docker image after build

Failed to run Docker image after build

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 537 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.
  • C Offline
    C Offline
    chrish10r
    wrote on last edited by chrish10r
    #1

    I'm a newbie in the docker and Qt world, so bear with me.. I've "succeeded" in building a docker image with the following Dockerfile:

    FROM public.ecr.aws/ubuntu/ubuntu:20.04
    
    RUN apt-get update
    
    RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
    # Install Dependencies
    RUN apt-get -y install software-properties-common wget build-essential autoconf git fuse libgl1-mesa-dev psmisc libpq-dev libssl-dev openssl libffi-dev zlib1g-dev libdbus-1-3 libpulse-mainloop-glib0 python3 python3-pip desktop-file-utils libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-composite0 libxcb-cursor0 libxcb-damage0 libxcb-dpms0 libxcb-dri2-0 libxcb-dri3-0 libxcb-ewmh2 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-record0 libxcb-render0 libxcb-res0 libxcb-screensaver0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libfontconfig libxcb-xkb1 libxkbcommon-x11-0 libegl1-mesa-dev unixodbc-dev clang-10 lld-10 clang-tidy-10 clang-format-10 ninja-build doxygen ccache
    
    
    # Update gcc for correct c++17 support
    # Possible value 7/8/9
    ARG GCC=9
    
    RUN apt-get install -y software-properties-common                         && \
        add-apt-repository ppa:ubuntu-toolchain-r/test                        && \
        apt-get update                                                        && \
        apt-get -y install g++-${GCC}                                         && \
        update-alternatives                                                      \
          --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC} 60                      \
          --slave /usr/bin/g++ g++ /usr/bin/g++-${GCC}                           \
          --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-${GCC}                  \
          --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-${GCC}                  \
          --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-${GCC}  &&  \
        update-alternatives --config gcc
    
    # Build cool cmake version (ubuntu 16.04 comes with cmake 3.5)
    ARG CMAKE=3.20.0
    
    RUN wget -c -nv https://github.com/Kitware/CMake/releases/download/v${CMAKE}/cmake-${CMAKE}.tar.gz && \
        tar zxvf cmake-${CMAKE}.tar.gz   && \
        rm -rf cmake-${CMAKE}.tar.gz     && \
        cd cmake-${CMAKE}                && \
        ./configure                      && \
        make -j $(nproc)                 && \
        make install                     && \
        cd ..                            && \
        rm -rf cmake-${CMAKE}
    
    # Install Qt
    ARG QT=5.15.1
    ARG QT_MODULES='qtscript qtwebengine'
    ARG QT_HOST=linux
    ARG QT_TARGET=desktop
    ARG QT_ARCH=
    
    # Download & Install Qt
    RUN pip3 install aqtinstall && \
        aqt install --outputdir /opt/qt ${QT} ${QT_HOST} ${QT_TARGET} ${QT_ARCH} -m ${QT_MODULES}
    
    ENV PATH /opt/qt/${QT}/gcc_64/bin:$PATH
    ENV QT_PLUGIN_PATH /opt/qt/${QT}/gcc_64/plugins/
    ENV QML_IMPORT_PATH /opt/qt/${QT}/gcc_64/qml/
    ENV QML2_IMPORT_PATH /opt/qt/${QT}/gcc_64/qml/
    ENV Qt5_DIR /opt/qt/${QT}/gcc_64/
    ENV Qt5_Dir /opt/qt/${QT}/gcc_64/
    ENV Qt6_DIR /opt/qt/${QT}/gcc_64/
    
    # Remove style i'm not interested in
    RUN rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/designer  && \
        rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/Fusion    && \
        rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/Imagine   && \
        rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/Universal
    
    # Install linuxdeployqt
    RUN wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" -O /usr/bin/linuxdeployqt && \
        chmod a+x /usr/bin/linuxdeployqt
        
    WORKDIR /src
    COPY src/ ./
    # RUN cmake . && make
    # RUN ctest
    CMD [ "/bin/bash" ]
    
    

    When I try to run the docker image in Docker Desktop I get the following error:

    Got keys from plugin meta data ("wayland-xcomposite-egl")
    QFactoryLoader::QFactoryLoader() looking at "/opt/qt/5.15.1/gcc_64/plugins/platforms/libqwayland-xcomposite-glx.so"
    Found metadata in lib /opt/qt/5.15.1/gcc_64/plugins/platforms/libqwayland-xcomposite-glx.so, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "wayland-xcomposite-glx"
            ]
        },
        "archreq": 0,
        "className": "QWaylandXCompositeGlxPlatformIntegrationPlugin",
        "debug": false,
        "version": 331520
    }
    
    
    Got keys from plugin meta data ("wayland-xcomposite-glx")
    QFactoryLoader::QFactoryLoader() looking at "/opt/qt/5.15.1/gcc_64/plugins/platforms/libqxcb.so"
    Found metadata in lib /opt/qt/5.15.1/gcc_64/plugins/platforms/libqxcb.so, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "xcb"
            ]
        },
        "archreq": 0,
        "className": "QXcbIntegrationPlugin",
        "debug": false,
        "version": 331520
    }
    
    
    Got keys from plugin meta data ("xcb")
    QFactoryLoader::QFactoryLoader() checking directory path "/src/platforms" ...
    loaded library "/opt/qt/5.15.1/gcc_64/plugins/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.
    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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
    
    Aborted
    
    

    The docker image is built without any errors. But when I try to run the docker I get the above error. How do I fix this?

    jsulmJ 1 Reply Last reply
    0
    • C chrish10r

      I'm a newbie in the docker and Qt world, so bear with me.. I've "succeeded" in building a docker image with the following Dockerfile:

      FROM public.ecr.aws/ubuntu/ubuntu:20.04
      
      RUN apt-get update
      
      RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
      # Install Dependencies
      RUN apt-get -y install software-properties-common wget build-essential autoconf git fuse libgl1-mesa-dev psmisc libpq-dev libssl-dev openssl libffi-dev zlib1g-dev libdbus-1-3 libpulse-mainloop-glib0 python3 python3-pip desktop-file-utils libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-composite0 libxcb-cursor0 libxcb-damage0 libxcb-dpms0 libxcb-dri2-0 libxcb-dri3-0 libxcb-ewmh2 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-record0 libxcb-render0 libxcb-res0 libxcb-screensaver0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libfontconfig libxcb-xkb1 libxkbcommon-x11-0 libegl1-mesa-dev unixodbc-dev clang-10 lld-10 clang-tidy-10 clang-format-10 ninja-build doxygen ccache
      
      
      # Update gcc for correct c++17 support
      # Possible value 7/8/9
      ARG GCC=9
      
      RUN apt-get install -y software-properties-common                         && \
          add-apt-repository ppa:ubuntu-toolchain-r/test                        && \
          apt-get update                                                        && \
          apt-get -y install g++-${GCC}                                         && \
          update-alternatives                                                      \
            --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC} 60                      \
            --slave /usr/bin/g++ g++ /usr/bin/g++-${GCC}                           \
            --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-${GCC}                  \
            --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-${GCC}                  \
            --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-${GCC}  &&  \
          update-alternatives --config gcc
      
      # Build cool cmake version (ubuntu 16.04 comes with cmake 3.5)
      ARG CMAKE=3.20.0
      
      RUN wget -c -nv https://github.com/Kitware/CMake/releases/download/v${CMAKE}/cmake-${CMAKE}.tar.gz && \
          tar zxvf cmake-${CMAKE}.tar.gz   && \
          rm -rf cmake-${CMAKE}.tar.gz     && \
          cd cmake-${CMAKE}                && \
          ./configure                      && \
          make -j $(nproc)                 && \
          make install                     && \
          cd ..                            && \
          rm -rf cmake-${CMAKE}
      
      # Install Qt
      ARG QT=5.15.1
      ARG QT_MODULES='qtscript qtwebengine'
      ARG QT_HOST=linux
      ARG QT_TARGET=desktop
      ARG QT_ARCH=
      
      # Download & Install Qt
      RUN pip3 install aqtinstall && \
          aqt install --outputdir /opt/qt ${QT} ${QT_HOST} ${QT_TARGET} ${QT_ARCH} -m ${QT_MODULES}
      
      ENV PATH /opt/qt/${QT}/gcc_64/bin:$PATH
      ENV QT_PLUGIN_PATH /opt/qt/${QT}/gcc_64/plugins/
      ENV QML_IMPORT_PATH /opt/qt/${QT}/gcc_64/qml/
      ENV QML2_IMPORT_PATH /opt/qt/${QT}/gcc_64/qml/
      ENV Qt5_DIR /opt/qt/${QT}/gcc_64/
      ENV Qt5_Dir /opt/qt/${QT}/gcc_64/
      ENV Qt6_DIR /opt/qt/${QT}/gcc_64/
      
      # Remove style i'm not interested in
      RUN rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/designer  && \
          rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/Fusion    && \
          rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/Imagine   && \
          rm -rf ${Qt5_DIR}/qml/QtQuick/Controls.2/Universal
      
      # Install linuxdeployqt
      RUN wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" -O /usr/bin/linuxdeployqt && \
          chmod a+x /usr/bin/linuxdeployqt
          
      WORKDIR /src
      COPY src/ ./
      # RUN cmake . && make
      # RUN ctest
      CMD [ "/bin/bash" ]
      
      

      When I try to run the docker image in Docker Desktop I get the following error:

      Got keys from plugin meta data ("wayland-xcomposite-egl")
      QFactoryLoader::QFactoryLoader() looking at "/opt/qt/5.15.1/gcc_64/plugins/platforms/libqwayland-xcomposite-glx.so"
      Found metadata in lib /opt/qt/5.15.1/gcc_64/plugins/platforms/libqwayland-xcomposite-glx.so, metadata=
      {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
              "Keys": [
                  "wayland-xcomposite-glx"
              ]
          },
          "archreq": 0,
          "className": "QWaylandXCompositeGlxPlatformIntegrationPlugin",
          "debug": false,
          "version": 331520
      }
      
      
      Got keys from plugin meta data ("wayland-xcomposite-glx")
      QFactoryLoader::QFactoryLoader() looking at "/opt/qt/5.15.1/gcc_64/plugins/platforms/libqxcb.so"
      Found metadata in lib /opt/qt/5.15.1/gcc_64/plugins/platforms/libqxcb.so, metadata=
      {
          "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
          "MetaData": {
              "Keys": [
                  "xcb"
              ]
          },
          "archreq": 0,
          "className": "QXcbIntegrationPlugin",
          "debug": false,
          "version": 331520
      }
      
      
      Got keys from plugin meta data ("xcb")
      QFactoryLoader::QFactoryLoader() checking directory path "/src/platforms" ...
      loaded library "/opt/qt/5.15.1/gcc_64/plugins/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.
      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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
      
      Aborted
      
      

      The docker image is built without any errors. But when I try to run the docker I get the above error. How do I fix this?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @chrish10r said in Failed to run Docker image after build:

      qt.qpa.xcb: could not connect to display

      Looks like no X server is running in your Docker image?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • jsulmJ jsulm

        @chrish10r said in Failed to run Docker image after build:

        qt.qpa.xcb: could not connect to display

        Looks like no X server is running in your Docker image?

        C Offline
        C Offline
        chrish10r
        wrote on last edited by
        #3

        @jsulm Could you please elaborate? What is an X-server and how do I include this in my Docker image? Sorry, I'm quite new to this...

        jsulmJ 1 Reply Last reply
        0
        • C chrish10r

          @jsulm Could you please elaborate? What is an X-server and how do I include this in my Docker image? Sorry, I'm quite new to this...

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @chrish10r https://en.wikipedia.org/wiki/X_Window_System
          http://wiki.ros.org/docker/Tutorials/GUI
          https://gursimar27.medium.com/run-gui-applications-in-a-docker-container-ca625bad4638

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

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