3

I have a nanoserver container up and running. I log into the container using

> docker run -it microsoft/nanoserver powershell

Inside, I create a simple hello world exe using the following command :

PS C:\> Add-Type -outputtype consoleapplication -outputassembly helloworld.exe 'public class helloworld{public static void Main(){System.Console.WriteLine("hello world");}}'

When I run helloworld.exe, there is no output on stdout. No error log file is generated. How do I debug this? Why isn't helloworld.exe throwing the output or error on stdout? How can I debug this?

PS C:\> ls

    Directory: C:\

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        8/24/2017  11:08 AM                Program Files
d-----        7/16/2016   5:39 PM                Program Files (x86)
d-r---         8/8/2017   3:11 AM                Users
d-----        8/24/2017  11:08 AM                Windows
-a----        8/24/2017  11:09 AM           2048 helloworld.exe
-a----       11/20/2016   5:02 PM           1894 License.txt


PS C:\> .\helloworld.exe
PS C:\> echo %ERRORLEVEL%
%ERRORLEVEL%
texens
  • 3,717
  • 5
  • 23
  • 23
  • In powershell, that should be "echo $LASTEXITCODE", which following your example for me yields (helpfully) -1073741515. I'm trying to debug something similar - I'm assuming some dependency is missing in nanoserver. – Marvin Sep 08 '17 at 14:29

1 Answers1

0

The reason that no console output is generated is because your executable is x86 and not x64. Nanoserver only supports x64 according to this link: https://www.ca.com/en/blog-developers/docker-containers-os-base-image.html

I ran into a similar problem when I copied a simple hello world executable built on command line with cl.exe. After checking whether the exe was 32 or 64 bit using dumpbin, I rebuilt the executable from the correct MS VS developer prompt, i.e. the one with native x64 toolset and settings. This time, I could see the console output of the app in the docker nanoserver container.

slampe
  • 11
  • 3