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.
You need to install Visual C++ redistributable.
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
This is quite an open-ended question, so it is not possible to give precise answer. Here are a few thoughts:
Note: by "Windows Core" in this answer I mean Core option of Windows Server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With