Unsolved problem with qt.qpa.plugin: running on a docker in Kubuntu
-
Because now I hit: "sudo docker run <IMAGE ID>" the OS does not complain with errors or something, but I do not see the application running on my laptop...What is going on?
-
Check the logs of your container.
And if I may, you should avoid running docker using sudo. Add your user to the docker group so you can do things directly.
-
So the problem is that Docker cannot run PyQt/GUI application, if I have understood correctly??
-
It may but you have additional work do to in order for it to be able to do that as shown by the tool I suggested above.
-
I found this tutorial: https://stackoverflow.com/questions/24095968/docker-for-gui-based-environments which as I see matches with https://github.com/mviereck/x11docker (that you posted), however I cannot understand if this command:
nividia-docker run --interactive --tty --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix/:/tmp/.X11-unix/ <docker_iamge>
demands to have NVIDIA GPU?? I run the docker on Kubuntu 20.04.1 LTS running on a VMware, so I cannot access GPU...
-
You can use that one if you have setup docker to run with NVIDIA hardware however, you can see from the main answer that it's not required at all.
-
So, what are the steps to make this tool https://github.com/mviereck/x11docker#single-applications work and generally to make the PyQt GUI application run on the docker?? Because I have tried a few tutorials, such as this: https://askubuntu.com/questions/1161646/is-it-possible-to-run-docker-container-and-show-its-graphical-application-window and this: https://askubuntu.com/questions/1249043/run-simple-x11-app-in-docker-container-on-ubuntu-20-04 and the only thing I get is errors!!
Such as this one:
Sending build context to Docker daemon 2.048kB Step 1/4 : FROM ubuntu:20.10 ---> ..... Step 2/4 : RUN apt-get update ---> Using cache ---> ..... Step 3/4 : RUN apt-get install -y x11-apps ---> Running in ..... Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package x11-apps The command '/bin/sh -c apt-get install -y x11-apps' returned a non-zero code: 100
-
X11-apps is not available on x86_64 architecture for Ubuntu 20.10.
In any case, you should not need it to run your application.
-
This post is deleted! -
Ok, after many days searching and experimenting I made this Dockerfile run:
FROM ubuntu:14.04 RUN apt-get update && apt-get install -y firefox # Replace 1000 with your user / group id RUN export uid=1000 gid=1000 && \ mkdir -p /home/developer && \ echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \ echo "developer:x:${uid}:" >> /etc/group && \ echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \ chmod 0440 /etc/sudoers.d/developer && \ chown ${uid}:${gid} -R /home/developer USER developer ENV HOME /home/developer CMD /usr/bin/firefox
source: http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
What modifications should I do in order to make my .py code file, inside which I use PyQt libraries, run???
Thanks...
-
I run this command:
sudo docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix my-code bash
but instead of get the GUI/PyQt5 application ruuning, I get this feedback:
root@<id_number>:/#
I run the command:
python3 code.py
and again the error:
Got keys from plugin meta data ("xcb") QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ... loaded library "/usr/local/lib/python3.8/dist-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" No protocol specified qt.qpa.xcb: could not connect to display :0 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.
-
I have also found this solution:
https://mindup.medium.com/running-gui-apps-securely-in-docker-sandbox-5d945288929b
I tried the first solution, ok I opened successfully the vnc Desktop and insert to the Desktop, but how do I run the Dockerfile? I mean If I install again the docker to the VNC Desktop OS and run the commands of building and running the Dockerfile, what is the new thing that docker solution provides?