Interacting with services in remote Windows machines from inside a Docker container

Currently I have a website running on a Windows IIS server that reaches out to other remote Windows servers to query the statuses of services installed on those remote machines. It is able to do so because the application on IIS is running using a service account that has the necessary permission on the domain to query/start/stop those services on the remote machines.

If I instead wanted to package and run this website as a Docker container, how would I be able to replicate this functionality? I would like to use a linux based container if at all possible.

Thank you for any advice!

You want to package a dedicated Windows web server with dedicated Windows services which use dedicated Windows API calls into a Linux container? Not sure if that is possible.

Windows binaries require Windows container. Though, if it’s an asp.net core application, you could use Kestrel web server.

I’m not attempting to package the current solution of IIS running on a Windows service account inside of the docker linux image if that’s what you’re thinking. I only stated those details to explain how I’m achieving the goal now (of my web app interacting with the remote Windows services). It might help to know that this is a line of business intranet app, not a public facing or more typical web site.

It is a .NET 6 application, but I’m afraid I don’t understand how Kestrel will help me out here. If you have further thoughts, please let me know.

No idea. I have no experience with .NET. I posted my response, because I knew people wrote and ran asp.net core web applications on Kestrel in Linux containers.

First you need to figure out if and how your .NET6 application can be run on Linux. Once this is clear, you can start to think about containerizing it. It is more likely users of a .NET community will know it…

Besides this functionality I’m asking about, the app will run on Linux just fine. But I think you’re correct, the root of the problem isn’t really Docker and that I should seek advice on a .NET forum… Thank you for your insight.

What is the protocol that your web application uses to communicate with these remote Windows services? Since you mentioned a service account with domain permissions, I assume it is something that uses integrated windows authentication.

It uses a ServiceController class in .NET which I do believe is Windows only. This class can directly connect to any service on any Windows machine. My best thought if I truly want to rehost the rest of the app using docker is to carve off this troublesome functionality and keep it on Windows as a REST API. Then my main app can just do REST calls to this API which then uses the ServiceController class as I use it today to handle services across the remote Windows servers.

Sounds like a plan :slight_smile:

Yes, ServiceController is Windows-only. I think it uses P/Invoke to call functions in ADVAPI32.dll . Your plan of splitting that functionality off, and providing a (properly secured) REST API for consumption by the main app is a good one. The main app may then run in a linux container.