Important: Please read the Qt Code of Conduct -

Run pyqt5 on docker with ui file

  • How to run simple python code that open UI file in a Windows container on Docker

    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)
    app = QApplication(sys.argv)
    window = Ui()


    # 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", "./" ]

    requirements file:


    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 "" 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
    cmd docker running
    only when I try to get



  • Lifetime Qt Champion


    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.

Log in to reply