0

Some container 101 here please. I can't see messages written to std::cout in the console like i would expect, when it's run in a windows server core container. I've tried the same scenario with a C# console app and it outputs unlike the example below. I feel that narrows it down to something on the C++ side of things.

The code

#include <iostream>

int main() 
{
    std::cout << "Hello World\n";
}

The Dockerfile

FROM mcr.microsoft.com/windows/servercore:ltsc2019
ADD Debug/ /
ENTRYPOINT [ "cmd.exe" ]

The commands

docker build -t cppnet .
docker run -it cppnet

The results, first running in the container and second running locally

enter image description here

Daniel Revell
  • 8,338
  • 14
  • 57
  • 95
  • Possible duplicate of [Redirecting command output in docker](https://stackoverflow.com/questions/34632959/redirecting-command-output-in-docker) – user6556709 Apr 30 '19 at 16:15
  • Interesting idea, thanks for sharing. Because I'm interactive in the shell, I don't think that's the issue. I've just tried it without the array, so just `ENTRYPOINT cmd.exe` and it didn't make any difference. – Daniel Revell Apr 30 '19 at 17:05
  • I've updated the question to reflect that a C# app will output, whereas a C++ app will not. – Daniel Revell Apr 30 '19 at 17:12
  • 1
    See this comment: https://stackoverflow.com/questions/49580984/c-print-line-not-printing-to-console-in-docker-container#comment86171434_49580984 – Niloct Apr 30 '19 at 17:16

0 Answers0