Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

700
Views
C# Application fails with "cannot start service from the command line" in docker but not on host

We have an in-house developed C# .NET application that we are trying to put in windows containers. The application was originally designed to run as a service but it seems to be that containers are better run as a process. So the devs have made some small changes and we can now run the application from the command line. It runs successfully on Win 10, 2012 R2, 2016, and 2019.

However, when trying to run the exact same application on a 2016 or 2019 container, we get the error message:

Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then start with the ServerExplorer, Windows Services Administrative tool or the NET START command.

Why would running in a container change the way the application runs? There are no dependencies (other than .NET) for the application that are not included with the application.

I'm able to successfully install the application as a service in the container and start the service without errors. However trying to curl http://localhost in the container or outside the container fails even with the port is exposed via the -p 80:80 option from docker run.

I've seen previous versions of this application run successfully in a docker container as a process so I figure it has to be some caveat of C# but I'm not a dev and I'm getting a standard "it runs on the host, it must be a docker thing" answer from our devs.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It turns out the code had an if statement on Environment.UserInteractive which told it whether to behave as console or service. In Windows Docker containers, the Environment.UserInteractive always triggers as false for some reason which forced the application to service even when run as a console. We used an environment variable to override the if.

Worth noting that apparently in .NET Core, the variable always triggers as true which may be helpful given the way Linux apps are usually triggered.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!