Cloud Native 9 min read

Using Docker and Windows Containers for Traditional .NET Development

This article explains how to set up a Windows development environment, enable Windows and Hyper‑V containers, create a Dockerfile for legacy .NET applications, build and run the container, and discusses practical considerations such as image size and deployment nuances.

DevOps
DevOps
DevOps
Using Docker and Windows Containers for Traditional .NET Development

The author introduces the Docker4Dev series, aiming to help developers use Docker on Windows, especially for traditional .NET (2.0/3.5/4.5) applications now that Windows Server 2016 supports production‑grade Windows Containers.

Three environment options are described: Windows Server 2016, Windows 10 (Pro/Enterprise), and Nano Server, with two container modes – Windows Server Container and Hyper‑V Container – illustrated by a diagram.

For a quick start on Windows 10, install Docker for Windows and run a PowerShell script to enable the required features:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Enable-WindowsOptionalFeature -Online -FeatureName containers -All
Restart-Computer -Force

After switching Docker to Windows Container mode, you can develop a traditional ASP.NET 4.5 app in Visual Studio 2017, then add a Dockerfile (named Dockerfile.windows ) to package the app. The Dockerfile uses a Windows IIS base image, installs .NET Framework, creates a website, exposes port 80, and copies the application files:

FROM harbor-bj.devopshub.cn/microsoft/iis
SHELL ["powershell"]

RUN Install-WindowsFeature Net-Framework-45-ASPNET ; \
  Install-WindowsFeature Web-Asp-Net45

ARG source=.
WORKDIR 'c:\app'

RUN Remove-Website -Name 'Default Web Site'
RUN New-Website -Name 'aspnet45docker' -Port 80 \
 -PhysicalPath 'c:\app' -ApplicationPool '.NET v4.5'

EXPOSE 80
COPY $source .

Build the image with:

docker build -f Dockerfile.windows -t aspnet45web01:win-v1 .

Run the container:

docker run -itd -p 81:80 aspnet45web01:win-v1

Because Docker for Windows does not automatically map localhost for Windows Containers, retrieve the container’s IP address using:

docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" <container id>

Access the app via the container’s IP on port 80, confirming that the legacy .NET site runs inside an IIS instance on a Windows Container.

The author notes that Windows Container images are large (e.g., WindowsServerCore ~4 GB), which can affect deployment speed, but once the base image is cached, subsequent updates are lightweight. Hyper‑V Containers provide stronger isolation and the potential to run Linux containers on Windows.

At the end, the article includes links to previous Docker4dotnet posts and a promotional notice for a paid three‑day Docker‑based DevOps training in Beijing.

dockerDevOpsIIS.NETwindows-containerPowerShell
DevOps
Written by

DevOps

Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.