Exploring Windows Containers
Key point
This piece summarizes how to run Windows-only applications in isolation using Windows Containers, along with their compatibility constraints.
Details
Windows Container is a feature for running Windows applications in isolation within a Windows Server environment, and it has been supported since Windows Server 2016. Similar to Linux Container, it provides an independent execution environment, but internally it operates based on the Windows kernel.
The base images are divided into 4 types provided by Microsoft. The more features included, the larger the image size, and Microsoft recommends Windows Server Core and Nanoserver for most users.
- Nano Server: about 300MB
- Server Core: about 5GB
- Windows: about 9GB, supported only up to Windows Server 2019(ltsc2019)
- Windows Server: about 10GB, supported from Windows Server 2022(ltsc2022) onward
The most important constraint is compatibility. Unlike Linux, Windows has user mode and kernel mode tightly coupled, so depending on the Host OS version, certain Windows Container images may not run. For example, on Windows 10, you cannot directly run a Windows Server 2022 image, and in practice you get the error docker: a Windows version 10.0.20348-based image is incompatible with a 10.0.19043 host.
As an example, the post shows the process of running a .NET Framework 4.5.2-based ASP.NET application as a Windows Container. After publishing the application, rather than running it directly on a Windows 10 Host, a Windows Server 2022 virtual machine is created using Hyper-V, and the Container is run on top of that.
The setup order is as follows.
- Download the Windows Server 2022 evaluation ISO and create a Hyper-V virtual machine
- Configure nested virtualization with
Set-VMProcessor -VMName "windows-server-2022" -ExposeVirtualizationExtensions $true - Add the necessary Windows Features with
Install-WindowsFeature -Name Hyper-VandInstall-WindowsFeature -Name Containers - Install Docker CE for Windows Server
- Copy the published ASP.NET output, then write a Dockerfile based on the
mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2022image - Build with
docker build -t my-aspnet-app .and run withdocker run -p 80:80 -d my-aspnet-app:latest
In closing, the post states that while Windows Container still has more constraints than Linux Container, it can be a practical alternative for services that cannot leave Windows. In particular, if pre-execution tasks such as COM modules, IIS settings, and Windows registry can be baked into the Dockerfile in advance, it can significantly reduce the cost of building and managing a Windows development/operations environment.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.