Cloud Native 5 min read

Can You Run Windows Inside Docker? A Practical Guide to Windows Containers

This article explains why and how to run Windows environments in Docker containers, compares the two container modes, lists supported Windows images, provides a quick Hello World example, and highlights the main limitations you should consider before adopting Windows containers.

Architect's Tech Stack
Architect's Tech Stack
Architect's Tech Stack
Can You Run Windows Inside Docker? A Practical Guide to Windows Containers

When you think of Docker, the first thing that comes to mind is Linux containers, built on cgroups and namespaces. The natural question is: can Windows run inside Docker containers?

The answer is yes—Microsoft and Docker have officially supported Windows containers for years.

Why Run Windows in Docker?

Common scenarios include quickly launching a Windows environment for testing, running legacy Windows‑only applications (e.g., older .NET Framework versions), and using Windows containers in CI/CD pipelines to avoid heavyweight virtual machines.

Two Windows Container Modes

Microsoft and Docker offer Windows Containers in two modes:

Windows Server Containers – use the host’s Windows kernel with isolation similar to Linux namespaces; they start fast and have low overhead.

Hyper‑V Containers – each container runs in a lightweight Hyper‑V VM with its own kernel, providing stronger isolation at the cost of slower startup.

In short, choose Server Containers for lightweight needs and Hyper‑V Containers for stronger isolation.

Which Windows Images Can You Use?

mcr.microsoft.com/windows/servercore

– a trimmed‑down Windows Server image that runs most applications. mcr.microsoft.com/windows/nanoserver – an ultra‑small image (tens of MB) with limited commands. mcr.microsoft.com/windows – a more complete image but very large.

The image version must match the host’s Windows kernel version, otherwise you’ll encounter compatibility errors.

Quick Hello World

If you are on Windows 10 Pro or Windows Server 2019, you can try the following:

# Switch Docker to Windows container mode
$Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon

# Pull an image
docker pull mcr.microsoft.com/windows/servercore:ltsc2019

# Run a container
docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 cmd

The container will launch a Windows command prompt.

Real‑World Pitfalls

Large image size – Server Core images start at 3–4 GB, whereas typical Linux images are only tens of MB.

Version compatibility – the host and container Windows kernel versions must align, or you’ll see errors such as “The operating system of the container does not match the host.”

Smaller ecosystem – most Docker images are Linux‑based, and Windows container use cases are relatively niche.

Conclusion

Running Windows in Docker is possible and can solve specific problems like CI pipelines or legacy app testing, but Linux containers remain the primary choice for production. Windows containers are best viewed as a complementary technology rather than a replacement.

Docker Windows illustration
Docker Windows illustration
DockerDevOpscontainerizationHyper-VWindows ContainersServer Core
Architect's Tech Stack
Written by

Architect's Tech Stack

Java backend, microservices, distributed systems, containerized programming, and more.

0 followers
Reader feedback

How this landed with the community

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.