A dockerized C++ windows console application exited with code 3221225781

I Have written a very simple c++ hello world program

#pragma once
#include <iostream>
#include <fstream>

int main()
{
   std::cout << "Hello Docker world!\n";
   return 0;
}

This is build as a release x64 windows console application and thus produces an exe

than I dockerize this program using the following dockerfile

FROM microsoft/windowsservercore

ADD ./DockerHello.exe /DockerHello.exe

# Run exe when the container launches
CMD C:\DockerHello.exe

However when i use docker run it will show nothing and when i use docker ps -a I see that it has exited with code 3221225781

From some online searching I understand that this apparently means that I am missing some dll or so, but I have no idea how to find out which?

Can anybody help me? Or tell me how I can get a simple c++ console application working in docker?

Cannot run my windows application in a container, helloworld.cpp : Defines the entry point for the console application. /quiet" #​CMD C:\Windows\System32\ipconfig.exe CMD C:\helloworld.exe succeeded processid=1848 exitCode=3221225781 [03:43:57.176][WindowsDaemon ][Info The exit code for the process indicates missing dependencies. The command 'cmd /S /C C:/myapp/myapp.exe --version' returned a non-zero code: 3221225781. Error 3221225781 appears to be a DLL loading error. The same application runs fine inside microsoft/windowsservercore but the resulting image is over 10 times the size, hence Nano server is attractive.

Most probably you are using the wrong docker image. Looking at this issue on github it looks like you need to be using the following Dockerfile:

FROM microsoft/dotnet-framework:4.6.2

ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:\vc_redist.x64.exe /quiet /install

ADD ./DockerHello.exe /DockerHello.exe

CMD C:\DockerHello.exe

P.S. I don't have windows to test this on, but if you play around with it, it should be working. Maybe it might work with the microsoft/windowsservercore image as well.

Using MSVC in a Docker Container for Your C++ Projects, Create a new Windows Console Application project in Visual Studio. Go to your project properties and under C/C++ change the Debug Information That also makes it easier to run again as we update our source code. A dockerized C++ windows console application exited with code 3221225781. This is build as a release x64 windows console application and thus produces an exe. However when i use docker run it will show nothing and when i use docker ps -a I see that it has exited with code 3221225781.

You can see the problem by using docker logs:

docker logs <container name or ID>

Containerize an app with Docker tutorial, NET Core app that the Docker container will run. If you're using Visual Studio Code, from the previous terminal session type the dotnet publish -c Release 7 minutes ago Exited (143) 20 seconds ago core-counter docker rm docker run -it --rm --entrypoint "cmd.exe" counter-image Microsoft Windows  2 A dockerized C++ windows console application exited with code 3221225781 Nov 22 '18 2 Python program with nuitka created exe and inno setup installer crashes: Faulting module python37.dll [duplicate] Apr 15 '19

Using Docker to build and deploy .Net Core console applications, You also need to bear in mind that in using Docker for Windows you are images are as small as possible by excluding any source code or build tools. RUN dotnet publish -c Release -o out # Build the runtime image FROM The first stops the application from exiting as it runs, while the second will  Code 3221225794-1073741502 · 0xC0000142 · C0000142. The application failed to initialize properly. Indicates that the application has been launched on a Desktop to which current user has no access rights. Another possible cause is that either gdi32.dll or user32.dll has failed to initialize.

Container is returning exit code 1 but build is successful · Issue #149 , yeikel changed the title Container exit with exit code 1 but build is successful The healthcheck should check if your application is running correctly. check if the desired container exited and check the exit-code - it should be easy as calling docker-compose ps. You signed in with another tab or window. Five simple steps to build a Dockerfile for a Windows application, which you can build into a Docker image and then run your app in a container.

What I learned making a Docker container for , Until recently, the only way to run Docker containers on Windows 10 was with Hyper-V, Microsoft's This saves us the cost of installing a GUI application that we cannot launch in a RUN C:\TEMP\install.cmd C:\TEMP\vs_buildtools.exe ` In practice, I have rarely been able to get the code I'm looking for. I believe that return code is a generic .NET console app crashed code. The way the job is set up in Task Scheduler is not causing this issue. Check the Application event log on the server for any errors that occurred near the time the job 'completed'.

Comments
  • How did you link DockerHello.exe for the runtime? Did you use /MT or /MD, if using MSVC? If you don't have the MSVC runtime in the Docker container and linked with /MD, it could fail to find the DLLs it requires.
  • I am using MSVS 2017. I do not understand what you mean by linking with /MD or /MT so it could very well be my problem
  • Every C or C++ application needs a runtime, a library that contains the core functionality of the C standard library (or C++), and MSVC allows you to statically link to a runtime when compiling code, so the runtime does not need to be installed on the computer the code is run on: msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
  • If you've ever wondered why you need to install "Visual C++ Redistributable Packages for Visual Studio 20XX" sometimes when running a new application, it's because the code was linked to a shared runtime (/MD), and so Windows needs to install that version of the runtime (a DLL) to use the code.
  • It was set to /MD I made it /MT and now it works. Thank you.
  • I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
  • The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
  • Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
  • I had found this before but it does not display anything for me