Any Windows version running in a Docker container!
- Unix/Linux System
- KVM
- Docker
Windows can run on the docker container thanks to KVM. It can do this thanks to the --device=/dev/kvm
parameter it gives to the docker container. This parameter allows the container to access the KVM device on the host machine. That's why we need to install KVM on the machine first.
This gist is based on Linux.
# 1. sudo apt update && sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager -y
# 2. usermod -aG libvirt $(whoami)
# 3. sudo systemctl start libvirtd
# 4. sudo systemctl enable libvirtd
# 5. sudo modprobe kvm
# 6. sudo nano /etc/modules
#
# To have KVM automatically installed at startup, edit the /etc/modules file and type "kvm" and
# add "kvm_intel" or "kvm_amd" modules:
#
# The contents of the file should look like this:
#
# """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
# # /etc/modules: kernel modules to load at boot time.
# #
# # This file contains the names of kernel modules that should be loaded
# # at boot time, one per line. Lines beginning with "#" are ignored.
#
# kvm
# kvm_intel
# kvm_amd
# """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
#
# Use the following command to check that KVM is started:
#
# 7. lsmod | grep kvm
#
# Check the "/dev/kvm" directory should have been created.
Then, run the docker command:
docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows
Since noVNC is bulky and there is no sound. After the system is installed, we can install RDP from the microsoft store and use the IP in the URL to which we connected with noVNC, that is, the system's own IP. After installing RDP, we can connect to ourselves and get faster performance. It might also be a good idea to increase some CPU, RAM, and storage space before doing this.
version: "3"
services:
windows:
image: dockurr/windows
container_name: windows
devices:
- /dev/kvm
cap_add:
- NET_ADMIN
ports:
- 8006:8006
- 3389:3389/tcp
- 3389:3389/udp
stop_grace_period: 2m
restart: on-failure
environment:
RAM_SIZE: "5G"
CPU_CORES: 3
DISK_SIZE: "100G"
VERSION: "win11"
Finally, the Windows version can be changed by selecting the appropriate version from the table on the relevant github page and clicking VERSION
in the environment section of the docker compose file.