How to Set Up Windows Server 2016 Windows Containers
Windows Server 2016 introduced native Windows container support, marking a significant milestone in Microsoft’s containerization strategy. Windows Containers allow applications to be packaged with their dependencies and runtime environment into portable, isolated units that can run consistently across different environments. Windows Server 2016 supports two container isolation modes: Windows Server Containers (process isolation, sharing the host OS kernel) and Hyper-V Containers (hardware-level isolation using a lightweight VM per container).
Windows Containers are managed using Docker Engine for Windows, which integrates with Windows through the Host Compute Service (HCS) and Host Networking Service (HNS). Applications built for Windows (IIS, ASP.NET, SQL Server tools, etc.) can be containerized and deployed using the same Docker workflow familiar from Linux environments, though using Windows-specific base images.
Prerequisites
To set up Windows Containers on Windows Server 2016 you need: Windows Server 2016 (Standard or Datacenter edition), at least 4 GB of RAM and 40 GB of disk space, internet access to download container images (or a local container registry), and administrative PowerShell access. For Hyper-V Containers, the Hyper-V role must also be installed.
Step 1: Install the Containers Feature
Install the Windows Containers feature using PowerShell:
Install-WindowsFeature -Name Containers
For Hyper-V Container support, also install the Hyper-V role:
Install-WindowsFeature -Name Hyper-V, Containers -IncludeManagementTools
Restart the server to complete feature installation:
Restart-Computer
Step 2: Install Docker Engine
After the restart, install Docker Engine using the DockerMsftProvider package from the PowerShell Gallery:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name Docker -ProviderName DockerMsftProvider -Force
Restart after Docker installation:
Restart-Computer
Step 3: Verify Docker Installation
After the restart, confirm Docker is running correctly:
docker version
Check the Docker service status:
Get-Service Docker
Run the Docker hello-world equivalent for Windows to verify basic container operation:
docker run mcr.microsoft.com/windows/nanoserver:1709 cmd /c echo "Hello Windows Containers"
Step 4: Pull Windows Container Base Images
Microsoft provides several Windows base images. The main ones available for Windows Server 2016 are Windows Server Core and Nano Server. Pull the Windows Server Core image for full .NET Framework compatibility:
docker pull mcr.microsoft.com/windows/servercore:ltsc2016
Pull the Nano Server image for lightweight deployments:
docker pull mcr.microsoft.com/windows/nanoserver:1607
List downloaded images:
docker images
Step 5: Run a Windows Server Container
Run an interactive Windows Server Container using the Server Core base image:
docker run -it mcr.microsoft.com/windows/servercore:ltsc2016 powershell
You will be dropped into a PowerShell session inside the container. This is a process-isolated container sharing the host’s Windows kernel. Run a detached container running IIS:
docker run -d -p 80:80 mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2016
List running containers:
docker ps
Step 6: Run a Hyper-V Container
Hyper-V Containers provide stronger isolation by running each container in its own lightweight VM. To run a container in Hyper-V isolation mode:
docker run -it --isolation=hyperv mcr.microsoft.com/windows/servercore:ltsc2016 powershell
Hyper-V Containers take slightly longer to start than process-isolated containers due to the VM initialization, but offer complete kernel-level isolation suitable for multi-tenant scenarios.
Step 7: Build a Custom Container Image
Create a Dockerfile to build a custom Windows container image. The following example creates an IIS container with a custom home page:
FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2016
RUN echo "Hello from Windows Server 2016 Container" > C:inetpubwwwrootindex.html
EXPOSE 80
Build the image from the Dockerfile:
docker build -t my-iis-app:v1 .
Run the custom image:
docker run -d -p 8080:80 my-iis-app:v1
Step 8: Manage Container Lifecycle
Stop a running container:
docker stop
Remove a stopped container:
docker rm
Windows Containers on Windows Server 2016 bring the benefits of container-based application packaging and deployment to the Windows ecosystem, enabling modern DevOps practices for Windows workloads with full compatibility for existing .NET Framework applications.