Docker Community Forums

Share and learn in the Docker community.

Cannot run my windows application in a container


(Xahro) #1

Hi. I’ve recently switched to Docker for Windows in attempt to move my Win64 application to docker container. After 3 days of examples, documents and experimentation I came to conclusion that I am not capable of even getting a simple HelloWorld C++ application running in a container. Please help!

So what do I have:

Simple VS2017 command line application that outputs a string:

 // helloworld.cpp : Defines the entry point for the console application.
 //
 
 #include "stdafx.h"
 #include <iostream>
 using namespace std;
 
 int main()
 {
 	cout << "Hello World!" << endl; 
     return 0;
 }

A simple Dockerfile:

FROM microsoft/windowsservercore:10.0.14393.2007
ADD ./helloworld.exe /helloworld.exe
ADD ./vc_redist.x64.exe /vc_redist.x64.exe
RUN cmd /C "c:\vc_redist.x64.exe /quiet"

#CMD C:\Windows\System32\ipconfig.exe
CMD C:\helloworld.exe

When running ipconfig.exe I get output as expected.

When running helloworld, I get nothing.

Can someone help me understand what I am doing wrong?

For reference, I’ve tried this on number of different environments (Windows Server 2016 and Windows 10 Pro 1709)

Thanks in advance!


(Sam) #2

what error do you get trying to run that sample application?


(Xahro) #3

Nothing obvious that I can see – no application output and nothing indicating errors in the host log files (or at least nothing I’ve noticed). Are there any good ways of debugging issues like that?

After closer evaluation of the log file I found this:

[03:43:56.764][WindowsDaemon  ][Info   ] debug: HCSShim::Container::CreateProcess id=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 config={"CommandLine":"cmd /S /C C:\\helloworld.exe","WorkingDirectory":"C:\\","CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}
[03:43:56.764][WindowsDaemon  ][Info   ] debug: HCSShim::Container::CreateProcess id=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 config={"CommandLine":"cmd /S /C C:\\helloworld.exe","WorkingDirectory":"C:\\","CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}
[03:43:56.947][WindowsDaemon  ][Info   ] debug: HCSShim::Container::CreateProcess succeeded id=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 processid=1848
[03:43:56.947][WindowsDaemon  ][Info   ] debug: HCSShim::Container::CreateProcess succeeded id=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 processid=1848
[03:43:56.947][WindowsDaemon  ][Info   ] debug: init process started [pid=1848 module=libcontainerd namespace=moby container=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9]
[03:43:56.947][WindowsDaemon  ][Info   ] debug: init process started [pid=1848 module=libcontainerd namespace=moby container=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9]
[03:43:56.947][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Stdio processid=1848
[03:43:56.947][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Stdio processid=1848
[03:43:56.947][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Stdio succeeded processid=1848
[03:43:56.947][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Stdio succeeded processid=1848
[03:43:56.948][WindowsDaemon  ][Info   ] debug: HCSShim::Process::CloseStdin processid=1848
[03:43:56.948][WindowsDaemon  ][Info   ] debug: HCSShim::Process::CloseStdin processid=1848
[03:43:56.948][WindowsDaemon  ][Info   ] debug: HCSShim::Process::CloseStdin succeeded processid=1848
[03:43:56.948][WindowsDaemon  ][Info   ] debug: HCSShim::Process::CloseStdin succeeded processid=1848
[03:43:56.948][WindowsDaemon  ][Info   ] debug: start() completed [module=libcontainerd namespace=moby container=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9]
[03:43:56.948][WindowsDaemon  ][Info   ] debug: start() completed [module=libcontainerd namespace=moby container=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9]
[03:43:56.948][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Wait processid=1848
[03:43:56.948][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Wait processid=1848
[03:43:56.948][WindowsDaemon  ][Info   ] sending event [module=libcontainerd namespace=moby container=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 event=start event-info={c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 init 1848 0 0001-01-01 00:00:00 +0000 UTC false false}]
[03:43:56.948][WindowsDaemon  ][Info   ] sending event [module=libcontainerd namespace=moby container=c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 event=start event-info={c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9 init 1848 0 0001-01-01 00:00:00 +0000 UTC false false}]
[03:43:56.953][ApiProxy       ][Info   ] time="2018-01-12T03:43:56-08:00" msg="proxy << POST /v1.35/containers/c0abf2d1c8da2f436ff63621e2c7c82b31e12ae710c98fe59e48690faadc0cc9/start\n"
[03:43:56.954][WindowsDaemon  ][Info   ] debug: Calling GET /v1.34/containers/json?limit=0
[03:43:56.954][LocalhostForwarder][Info   ] Reconciliation succeeded
[03:43:56.954][WindowsDaemon  ][Info   ] debug: Calling GET /v1.34/containers/json?limit=0
[03:43:57.174][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Wait succeeded processid=1848
[03:43:57.174][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Wait succeeded processid=1848
[03:43:57.174][WindowsDaemon  ][Info   ] debug: HCSShim::Process::ExitCode processid=1848
[03:43:57.175][WindowsDaemon  ][Info   ] debug: HCSShim::Process::ExitCode processid=1848
[03:43:57.175][WindowsDaemon  ][Info   ] debug: HCSShim::Process::properties processid=1848
[03:43:57.175][WindowsDaemon  ][Info   ] debug: HCSShim::Process::properties processid=1848
[03:43:57.175][WindowsDaemon  ][Info   ] debug: HCSShim::Process::properties succeeded processid=1848, properties={"ProcessId":1848,"Exited":true,"ExitCode":3221225781,"LastWaitResult":0}
[03:43:57.175][WindowsDaemon  ][Info   ] debug: HCSShim::Process::properties succeeded processid=1848, properties={"ProcessId":1848,"Exited":true,"ExitCode":3221225781,"LastWaitResult":0}
[03:43:57.175][WindowsDaemon  ][Info   ] debug: HCSShim::Process::ExitCode succeeded processid=1848 exitCode=3221225781
[03:43:57.176][WindowsDaemon  ][Info   ] debug: HCSShim::Process::ExitCode succeeded processid=1848 exitCode=3221225781
[03:43:57.176][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Close processid=1848
[03:43:57.176][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Close succeeded processid=1848
[03:43:57.176][WindowsDaemon  ][Info   ] debug: HCSShim::Process::Close processid=1848

The exit code for the process indicates missing dependencies. I don’t have a lot of experience tracking that in containers – any pointers?


(Sam) #4

i would start the container with docker run -it etc…

which should give you a command prompt so that you can do all the normal debug


(Xahro) #5

According to depends.exe i’m missing number of key runtime dlls (vcruntime140.dll, msvcp140 … all vs14 runtime dlls).

Looking through the container I have them in c:\windows\system32 folder. That is why I had the vc_redist exe installed.


(Sam) #6

whos windows/system32 folder? must be IN the container, not ON the host.

check the path, obviously something is missing… but at least u have a place to start debugging


(Xahro) #7

And face palm – I was running x86 version of my app in the container. Thank you sdetweil for your help – problem solved.


(Sam) #8

always something!!.. glad u found it so fast…