Do you have a console application you have written using the .NET 4.6 Framework? Want to quickly get it going in a container? Thanks to Windows Containers, we can do this quite easily. This guide assumes you have Docker for Windows installed (requires Windows 10 Professional or later). If you don’t, you could do this on an AWS instance - they have a Windows Server 2016 with Containers instance that is perfect for this.

Step 1: Create a new directory called container.

Step 2: In this directory, create another new directory called publish and copy your built/published files into it.

Step 3: In the container directory, create a file named Dockerfile and add the following, replacing ConsoleApp.exe with the name of your executable:

FROM microsoft/windowsservercore
ADD publish/ /
ENTRYPOINT ConsoleApp.exe

This will then mean once you have built the image, you can run your console app by running the Docker container.

Step 4: We build the container. Run the following command in the command line after navigating to your container folder:

docker build . -t consoleapp

Step 5: We can then run the container by running the following command:

docker run consoleapp

And there you have it - super simple and super easy. Perfect those legacy scheduled tasks you have sitting around that you would rather not pay for a dedicated server for.