Tech Explorer Logo

Search Content

Running Windows in Docker: Complete Guide and Best Practices

3 min read
Cover image for Running Windows in Docker: Complete Guide and Best Practices

Introduction

Ever wondered if you could run a full Windows system inside a Docker container? What once seemed impossible is now a reality thanks to dockur/windows, a groundbreaking solution that lets you run Windows 11, 10, and even classic Windows 7 smoothly within Docker containers.

This guide will walk you through the process of achieving this seemingly impossible task, transforming your Docker container into a fully functional Windows workstation.

RDP Remote Desktop

💡 If you’re interested in running Windows in Docker, this tutorial will guide you step by step through the process.

Why Run Windows in Docker?

Before diving into the technical details, let’s understand the benefits of running Windows in Docker:

  • 🚀 Rapid deployment and migration
  • 💾 Lower resource overhead
  • 🔄 Multiple version coexistence
  • 🛠️ Simplified environment management
  • 🔒 Enhanced isolation

dockur/windows Features Overview

dockur/windows offers these core capabilities:

  • ✨ Support for multiple Windows versions (11/10/8.1/7/XP and more)
  • 🔄 Automatic ISO downloading
  • ⚡ KVM acceleration support
  • 🌐 Web-based remote access
  • 🖥️ RDP remote desktop support
  • 💽 Flexible storage configuration
  • ⚙️ Customizable CPU and memory allocation
  • 💪 ARM version support Check ARM version here

System Requirements

Before starting, ensure your system meets these prerequisites:

💡 If you’re testing in VirtualBox, remember to enable virtualization support first.

Enable Virtualization Support

RequirementMinimumRecommended
OSLinux (KVM support)Ubuntu 22.04+
CPUVirtualization capable4+ cores
Memory4GB8GB+
Storage20GB free spaceSSD storage

Basic Installation and Configuration

1. Deploy with Docker Compose

Create a compose.yml file:

   services:
  windows:
    image: dockurr/windows
    container_name: windows
    environment:
      VERSION: "11"    # Choose Windows version
    devices:
      - /dev/kvm      # KVM device mapping
    cap_add:
      - NET_ADMIN
    ports:
      - 8006:8006     # Web access port
      - 3389:3389/tcp # RDP ports
      - 3389:3389/udp
    volumes:
      - /home/vir-docker/data:/storage  # Windows image will be created on your local drive
    stop_grace_period: 2m # Grace period for clean shutdown

💡 Graceful shutdown enabled

Graceful Shutdown

2. Launch the Container

   docker-compose up -d

System Configuration Guide

Windows Version Selection

Choose different Windows versions by setting the VERSION environment variable:

CodeVersionImage Size
11Windows 11 Pro5.4 GB
11lWindows 11 LTSC4.2 GB
11eWindows 11 Enterprise5.8 GB
10Windows 10 Pro5.7 GB
10lWindows 10 LTSC4.6 GB
10eWindows 10 Enterprise5.2 GB
8Windows 8.1 Pro4.0 GB
8eWindows 8.1 Enterprise3.7 GB
7eWindows 7 Enterprise3.0 GB
veWindows Vista Enterprise3.0 GB
xpWindows XP Professional0.6 GB
2025Windows Server 20255.0 GB
2022Windows Server 20224.7 GB
2019Windows Server 20195.3 GB
2016Windows Server 20166.5 GB
2012Windows Server 20124.3 GB
2008Windows Server 20083.0 GB
2003Windows Server 20030.6 GB

Storage Configuration

Modify default storage location:

   volumes:
  - /var/win:/storage  # Custom storage path

Adjust disk sizes:

   environment:
  DISK_SIZE: "256G"   # Primary disk size
  DISK2_SIZE: "32G"   # Secondary disk size
  DISK3_SIZE: "64G"   # Third disk size
volumes:
  - /var/win:/storage    # Primary disk path
  - /home/win:/storage2  # Secondary disk path
  - /mnt/win:/storage3   # Third disk path

System Resource Allocation

Configure CPU and memory:

   environment:
  RAM_SIZE: "8G"      # Allocate 8GB RAM
  CPU_CORES: "4"      # Allocate 4 CPU cores

Language Customization

By default, Windows installs in English. Set a different language using the LANGUAGE environment variable:

   environment:
  LANGUAGE: "English"  # Set Windows language

Supported languages include:

LanguageSettingLanguageSetting
EnglishEnglishChineseChinese
JapaneseJapaneseKoreanKorean
FrenchFrenchGermanGerman
SpanishSpanishRussianRussian
ItalianItalianPortuguesePortuguese

💡 Tip: Choose officially supported languages for best stability and compatibility.

Remote Access Setup

Web Access

  1. Access http://your-host-ip:8006 after container launch
    Web Access
  2. Wait for automatic installation
  3. Installation is complete when Windows desktop appears

RDP Remote Desktop

  1. Connect using any RDP client to your-host-ip:3389
  2. Default username: Docker
  3. Default password: none

Custom Credentials

   environment:
  USERNAME: "admin"
  PASSWORD: "secure_password"

Advanced Configuration

Custom Installation Scripts

Create and mount install.bat:

   volumes:
  - /path/to/scripts:/oem

DHCP Network Configuration

Enable DHCP:

   environment:
  DHCP: "Y"
devices:
  - /dev/vhost-net
device_cgroup_rules:
  - 'c *:* rwm'

Troubleshooting

KVM Support Verification

Check KVM support:

   sudo apt install cpu-checker
sudo kvm-ok

Performance Optimization Tips

  1. Enable CPU virtualization extensions
  2. Use SSD storage
  3. Allocate sufficient system resources
  4. Consider macvlan networking for better performance

Conclusion

dockur/windows provides a powerful and flexible solution for running Windows systems in Docker containers. This guide enables you to easily deploy and manage Windows in Docker, opening new possibilities for development, testing, and virtualization scenarios.

References

Share