Unsolved Run pyqt5 on docker with ui file
-
How to run simple python code that open UI file in a Windows container on Docker
Paython:from PyQt5.QtWidgets import QMainWindow, QApplication from PyQt5 import uic import sys class Ui(QMainWindow): def __init__(self): super(Ui, self).__init__() uic.loadUi('mainWindow.ui', self) self.show() app = QApplication(sys.argv) window = Ui() app.exec_()
Dockerfile:
# set base image (host OS) FROM python:3.7 # set the working directory in the container WORKDIR /code # copy the dependencies file to the working directory COPY requirements.txt . # install dependencies RUN pip install -r requirements.txt # copy the content of the local src directory to the working directory COPY / . # command to run on container start CMD [ "python", "./main.py" ]
requirements file:
PyQt5==5.15.2 PyQt5-sip==12.8.1
the Docker build command
docker built -t myimage .
run the docker command:
docker run -e DISPLAY="My IP":0 -p 5000:5000 myimage
when I go to "127.0.0.1:5000" this is not working how to fix this?
-
@eranp03 said in Run pyqt5 on docker with ui file:
this is not working
What does not work? There is no error message anywhere? How is docker at issue here?
-
@JonB
There is no error message on CMD
only when I try to getlocalhost:5000
-
Hi,
Your application does not run a web server therefore trying to access it with a web browser won't work.
You will have to have a X11 server running on your Windows machine.
See this article for an explanation about that.