1

I'm working on a feature for a .NET application that requires to know if the host which the application runs on is a windows container. I could not find information anywhere about this. It is possible if the host is linux but not sure if it is windows. Any helps would be really appreciated.

Thanks

stoney78us
  • 195
  • 2
  • 5
  • 17

1 Answers1

0

I found this link How to check the OS version at runtime e.g. windows or linux without using a conditional compilation statement.

System.Environment.OSVersion.Platform can be used for this purpose.

Chun-Yen Wang
  • 568
  • 2
  • 10
  • how do I check the .NET application is running in a docker container with this ? – stoney78us Jan 12 '18 at 01:12
  • @Chun This is not an answer to the question. If the container is a linux container, the code you have provided will always indicate linux, even if the machine hosting the container is MacOS or Windows. – ProgrammingLlama Jan 12 '18 at 06:15