简体   繁体   中英

Running a basic Qt application in Docker

I am trying to run a basic console application ( developed in Qt ) in docker for windows. Development environment is windows 10, compiler VC2015, 32bit Application.

It is hello world and idea was to find the issues, before I try to port the actual application.

The code is simplest c++ code:

#include <QCoreApplication>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
   QCoreApplication a(argc, argv);
   std::cout<<"Hello world";

   return a.exec();
}

The Dockerfile is:

# Comment:

#It needs a Microsoft environment to run
FROM microsoft/nanoserver:latest


#Create a folder inside the home folder in the Container Operating System
RUN mkdir -p C:\HelloWorld


#Copy the excutable from this folder to the folder inside the Container 
Operating System.
COPY . /HelloWorld/

#Run the application inside the container operating system.
CMD ["C:\\HelloWorld\\docker_HelloWorld.exe"]

My expected end result was a console/shell output of "Hello world". But I get nothing. Can someone point out what is missing?

Thanks.

I suspect that nanoserver images only supports x64 applications, if possible please build your application as x64 and run it inside the nanoserver with its dependencies.

If not possible to build as x64, then you can use windowsservercore containers to run the x86 applications.

You should copy the dependency assemblies with that application, other wise it will not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM