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:
Create a new project with Q Studio containing only a Web presentation engine (remove Native presentation engine).
Esportare la QApplication in una cartella e selezionare la piattaforma Debian 64-bit.
Copy the generated QApplication folder from the previous step into a folder.
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.
Once the
Dockerfile
has been created, launch the following commands via PowerShell:Create the image using the following command:
docker build -t $imageTag .
where
$imageTag
is the name of the imge.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.
Based on the selected protocol (either
http
orhttps
), open the following web page:http://localhost:<externalPort>
https://localhost:<externalPort>