Important: Please read the Qt Code of Conduct -

Qt error in Docker with Mayavi Application

  • The goal: Create a Docker container to implement a Mayavi based application. The application should accept data points and create a 3d image. Th GUI portion of Mayavi is not absolutely necessary, however is used when the application runs.

    The Docker image is created with the following:

    FROM python:3.7
    RUN mkdir /src
    WORKDIR /src
    RUN apt-get update && apt-get install -y \
        libgl1-mesa-dev \
        libqt5x11extras5 \
        libxkbcommon-x11-0 \
        libxcb-randr0-dev \
        libxcb-xtest0-dev \
        libxcb-xinerama0-dev \
        libxcb-shape0-dev \
        libxcb-xkb-dev \
    RUN python3 -m pip install numpy==1.18.1 \
        && python3 -m pip install vtk==8.1.2 \
        && python3 -m pip install mayavi==4.7.1 \
        && python3 -m pip install pyqt5==5.14.0 
    COPY .
    CMD ["python3.7", ""]

    The container is created without incident. When the container is run the following error is received:

    Got keys from plugin meta data ("xcb")
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/bin/platforms" ...
    loaded library "/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/"
    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, webgl, xcb.

    Any ideas on how to solve this problem?

    PS: Read about needing to connect a container to a host's X server for display. If this is indeed the case what is the solution for unknown host such as an Amazon instance?

  • Lifetime Qt Champion

    @TheLoneliestMonk said in Qt error in Docker with Mayavi Application:

    qt.qpa.xcb: could not connect to display

    Looks like there is no X11 running, but I'm not a Docker expert.

  • Perhaps you could use xvfb or xvfb-run, these are common solutions at least in CIs

Log in to reply