Skip to content
Alternative way to run Windows VM on Linux (Docker)

Alternative way to run Windows VM on Linux (Docker)

Updated: at 11:14 PM

Table of contents

Open Table of contents

Intro

As a Linux user, I often find the need to run software designed primarily for Windows or to test various Windows-specific applications.

Unfortunately, I found that using VMware and VirtualBox for running Windows virtual machines was not ideal. The performance on these applications was quite laggy on my laptop, which lacks the necessary resources to ensure a seamless experience. Therefore, I started exploring alternative methods to run Windows on Linux.

Solution

So, I want to present the solution I found: Windows on Docker.

Docker

Docker is a platform that uses containerization technology to run applications in isolated environments called containers. Unlike traditional virtual machines, Docker containers share the host system’s kernel, making them lightweight and efficient for running applications with minimal overhead. To install it on your system:

# Debian / Ubuntu
sudo apt install docker.io
# I Use Arch btw
yay -S docker
# For other distros, check following link
# https://docs.docker.com/engine/install/

And we will use following image:

Windows that will run inside a Docker container!

Installing Windows

Create a file called docker-compose.yml, then (optionally) create a folder storage for Windows image files and shared for a folder that will be shared between Host and Virtual machines.

Next, we need to modify docker-compose.yml. My configuration is the following:

services:
  windows:
    image: dockurr/windows
    container_name: windows
    environment:
      VERSION: "win10" # specify what Windows you want to run
      DISK_SIZE: "25G" # it is optional, you can specify the disk size to allocate
      RAM_SIZE: "3G" # the same for RAM
      CPU_CORES: "2" # and CPU cores. 
    devices:
      - /dev/kvm # if you have KVM
    volumes:
      - ./storage:/storage # Windows images will be in this folder both on your machine and in the container
      - ./shared:/shared # The same for shared folder
    cap_add:
      - NET_ADMIN # it grants to container administrative privileges for network-related operations
    ports:
      - 8006:8006 # Web Interface
      - 3389:3389/tcp # RDP
      - 3389:3389/udp
    stop_grace_period: 2m 

Make this up:

docker compose up -d

( You may need to install compose plugin too: https://docs.docker.com/desktop/install/linux-install/)

You will need to wait till Windows image is downloaded and built. To see progress, connect to localhost:8006, or docker logs <container-id>. (To get <container-id>, run docker ps)

Finally, qemu — an open-source emulator and virtualizer that enables you to run VM, will run the Windows in docker container.

Connecting to Windows

You can use the machine from the web, or connect with RDP which is more preferable. Get IP of the machine with docker inspect <container-id> | grep IPAddress.

windows getting up

I will use xfreerdp tool to connect via RDP. Username is docker and the command is following:

xfreerdp /u:docker /v:172.25.0.2 /dynamic-resolution

Voila, running Windows in Docker Container:

windows on docker

Shared folder is \\host.lan.

Conclusion

In conclusion, I suggest you to check documentation of the docker image for other configurations. Additionally, check my repo https://github.com/ElnurBDa/win10dockerconfig which includes two scripts for starting and stopping the Windows, you may bind them to some keyboard shortcuts.

Thanks for reading!! If you have some other alternatives for running Windows on Linux, let us know in comments :)

Note! This post was transfered from Medium: https://medium.com/@elnurbda/alternative-way-to-run-windows-vm-on-linux-docker-6d9828b3586c