Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trouble debugging error with exit code 3221225781 (missing libraries) in windows docker container

i'm trying to run a docker container on Windows 10 which should execute a windows executable (myprogram.exe). Below you find my dockerfile:

FROM microsoft/windowsservercore
COPY mydir/myprogram.exe /mydir/
CMD ["/mydir/myprogram.exe","someparameter"]

So i build the image with: docker image build --tag myimage . and run the container with: docker run myimage Unfortunately if I check the status of the container with: docker ps -a I can see that the container has exited with

exit code 3221225781

, which seems to point to a missing dll. To debug the problem I run the command: docker run -it --name debug microsoft/windowsservercore cmd, stopped the container and copied the windows executable in the container file system : docker cp myprogram.exe debug:c:/myprogram.exe Now I start the container again using docker start -i debug and enter myprogram.exe myparameter. Unfortunately the program exits immediately (usually it runs about 30 sec) without any output, error code ... My only explanation for this behavior is that if some cmd program is missing some dll's the corresponding error message is not included in the STDERR but rather in a message dialog. Apparently docker doesn't support this feature??? So what is the best was to solve this problem. Using dependency walker to go through all dll's needed is possible but would take some time and I'm looking for some more elegant solution.

like image 926
airborne Avatar asked Mar 21 '18 17:03

airborne


2 Answers

You need to install Visual C++ redistributable.

  1. Download the appropriate version of vc_redist.x64.exe and place it in the folder containing your Dockerfile
  2. Edit your Dockerfile so you preinstall VC++ redistributables when you build your image by adding:

    FROM mcr.microsoft.com/windows/sservercore

    WORKDIR c:\mydir

    COPY "vc_redist.x64.exe" .

    RUN vc_redist.x64.exe /install /passive /norestart /log out.txt

    COPY mydir/myprogram.exe c:\mydir

    CMD ["c:\mydir\myprogram.exe","someparameter"]

Your application should run now.

Note: you need 64-bit build of VC++ redistributable and the appropriate version. You can find some download urls here

like image 189
Cosmin Sontu Avatar answered Sep 21 '22 23:09

Cosmin Sontu


This is quite an open-ended question, so it is not possible to give precise answer. Here are a few thoughts:

  1. This is your program that is missing a dependency. Presumably, you as the program author should be aware of what dependencies are required. You need to make sure to include them in your docker image, when you build it.
  2. You are creating your image based on Windows Core, which does not have the whole slew of UI components. This looks like the most obvious thing that could go wrong, given the symptoms. So what I would do is try and make sure that your program can run on Windows Core in principle. Which brings me to the next point.
  3. The most practical way to troubleshoot, in my opinion, is to remove Docker from the equation. You want to run your program on Windows Core. So setup a machine (physical or VM) with Windows Core inside and try to run your program there. There is a good chance that it won't run with the same symptoms. If that's the case, you now have reduced complexity, because you know that your problem has nothing to do with docker (or not).
  4. Finally, when you have your Windows Core machine up and running, you might be able to see a message box pop up with the error immediately (even on Core you can run some programs with UI can run, and message boxes are not an uncommon site), and failing that you can run sysinternals procmon/procexp even on Windows Core, so using those to locate missing dependencies could help. There is also Dependencies.

Note: by "Windows Core" in this answer I mean Core option of Windows Server

like image 25
Andrew Savinykh Avatar answered Sep 19 '22 23:09

Andrew Savinykh