Search code examples
dockerqtopencvdockerfiledocker-image

Qt platform plugin Error in runnig container. how to show open cv output image with docker container on linux?


I wanna create a docker image on windows and image base [in docker file] for docker image would be linux os. My program uses the open-cv program which its output image has to be shown with CV2.imshow(). but after running container, I get this error.

please help to fix it.

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.9/site-packages/cv2/qt/plugins" 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: xcb.

Solution

  • I had this same issue and none of the solutions I looked up solved the issue for me. I even used xhost + and imshow still did not work.

    I was using the image tensorflow/tensorflow:2.7.0-gpu as my base image for my project. Seems like the package libsm6 is missing for some reason, and doing apt install libsm6 made it work.

    Hope this helped!