Q Application on a Docker containerΒΆ

This page illustrates the main steps required to run a QApplication in a docker container based on Debian10 using the Web UI for displaying the user interface with a web browser.

Setup

To create and test a container, Docker is required.

Once docker has been set up correctly, follow these steps to launch a QApplication in a container:

  1. Create a new project with Q Studio containing only a Web presentation engine (remove Native presentation engine).

  2. Esportare la QApplication in una cartella e selezionare la piattaforma Debian 64-bit.

  3. Copy the generated QApplication folder from the previous step into a folder.

  4. Create the Dockerfile in the folder created in the previous step. The file should contain the following code, which can be customized at a later time.

    FROM debian:10
    LABEL maintainer=youremail@company.com
    
    WORKDIR /app
    RUN chmod 777 /app
    
    RUN mkdir -p /app/QApplication
    ADD QApplication /app/QApplication/
    CMD /app/QApplication/QRuntime -c
    

    This file contains a minimal configuration to run the QApplication inside a container. However, when creating the container, the QApplication folder is copied inside the container.

  5. Once the Dockerfile has been created, launch the following commands via PowerShell:

    1. Create the image using the following command:

      docker build -t $imageTag .
      

      where $imageTag is the name of the imge.

    2. Run the image in a container:

      docker run -p externalPort:InternalPort --name containerName image
      

      where the -p option allows specifying an internal port of the container that can be accessed externally, e.g. a web browser. In this case, InternalPort is the Port property of the Web presentation engine in QStudio. On the other hand, ExternalPort is an unused port available on the running machine.

  6. Based on the selected protocol (either http or https), open the following web page:

    1. http://localhost:<externalPort>

    2. https://localhost:<externalPort>