Run pyqt5 on docker with ui file
Unsolved
Qt for Python
-
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?
-
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?