C# Console.ReadLine ends in infinite loop

Hi,
I have a .NET 4.6 Console application, that waits on an “Exit” input to close the application:

internal static void RunConsole(string args)
{
Program.Start(args);
Console.WriteLine(“Type ‘exit’ for shutdown.”);
StopIfExitIsWritten();
}
private static void StopIfExitIsWritten()
{
var line = Console.In.ReadLine();
if (line != null && line.Equals(“EXIT”, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(“Exit was requested.”);
Program.Stop();
}
else
{
StopIfExitIsWritten();
}
}

Executing the application on windows works without any problem. Starting using the Docker “Container Run …” command works without any problems. Starting the Container using “Docker Compose” results in the following Exception:

I added some debug informations behind “Console.ReadLine()”, a “Console.WriteLine(“info”)”, and this output was written permanently.
This means, that “Console.ReadLine()” does not blocks until the user hits “Enter” as described in MSDN.

What can I do to handle this problem?
Best regards,
Christian

Try to run your docker on interactive mode