dockur/windows

repository·master·Indexed 13 days ago

https://github.com/dockur/windows

Run Windows operating systems inside a Docker container with automatic installation and KVM acceleration for near-native performance. Supports various networking modes, RDP and web-based access, and extensive configuration via environment variables for CPU, RAM, and storage.

Tokens
5K
Snippets
19
Records
31
Agent score
97%

What's inside dockur/windows

  1. Run Windows using Docker CLI

    master

    You can start the Windows container directly via the Docker CLI. Ensure you have the necessary devices (/dev/kvm and /dev/net/tun) available on your host.

    docker run -it --rm --name windows -e "VERSION=11" -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v "${PWD:-.}/windows:/storage" --stop-timeout 120 docker.io/dockurr/windows
  2. Add multiple disks or pass through devices

    master

    You can add extra virtual disks by defining DISK2_SIZE, DISK3_SIZE, etc., and binding them to /storage2, /storage3, etc. You can also pass through physical disk devices or USB devices directly to the container.

    environment:
      DISK2_SIZE: "32G"
      DISK3_SIZE: "64G"
    volumes:
      - ./example2:/storage2
      - ./example3:/storage3
    
    devices:
      - /dev/sdb:/disk1
      - /dev/sdc1:/disk2
  3. Run Windows using Docker Compose

    master

    To run Windows in a Docker container using Docker Compose, create a docker-compose.yml file with the following configuration. This setup includes KVM acceleration, networking capabilities, and port mapping for the web interface (8006) and RDP (3389).

    services:
      windows:
        image: dockurr/windows
        container_name: windows
        environment:
          VERSION: "11"
        devices:
          - /dev/kvm
          - /dev/net/tun
        cap_add:
          - NET_ADMIN
        ports:
          - 8006:8006
          - 3389:3389/tcp
          - 3389:3389/udp
        volumes:
          - ./windows:/storage
        restart: always
        stop_grace_period: 2m
  4. Assign an individual IP address via macvlan

    master

    To give the container its own IP on your network instead of sharing the host's IP, create a macvlan network and assign it to the service. Note that the container will not be able to communicate with the Docker host via this IP without additional workarounds.

    docker network create -d macvlan \
        --subnet=192.168.0.0/24 \
        --gateway=192.168.0.1 \
        --ip-range=192.168.0.100/28 \
        -o parent=eth0 vlan
    services:
      windows:
        networks:
          vlan:
            ipv4_address: 192.168.0.100
    
    networks:
      vlan:
        external: true
  5. Deploy Windows on Kubernetes

    master

    To deploy the Windows container on a Kubernetes cluster, apply the official manifest from the repository:

    kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/master/kubernetes.yml
  6. Run commands or scripts after installation

    master

    You can automate post-installation tasks in two ways:

    1. Single Command: Use the COMMAND environment variable to run a specific command.
    2. Scripts/Files: Bind a folder to /oem. Any file named install.bat inside that folder will be executed during the final step of the automatic installation.
    environment:
      COMMAND: 'reg add "HKLM\\Software\\Example" /v Enabled /t REG_DWORD /d 1 /f'
    
    volumes:
      - ./example:/oem
  7. Connect via RDP

    master

    For a better experience than the web viewer (which lacks clipboard sharing and responsiveness), connect via Microsoft Remote Desktop. Use the container's IP address with the following credentials:

    • Username: Docker
    • Password: admin

    (Note: If you configured custom credentials via USERNAME and PASSWORD environment variables, use those instead.)

  8. Configure Display and Web UI

    master

    Manage how you view the Windows desktop:

    Display Backend

    • DISPLAY: Display backend (web, vnc, disabled, or none). Default is web.
    • LOSSY: Enables lossy VNC compression. Default is N.
    • VGA: QEMU video adapter model. Default is virtio.
    • WIDTH: Display width. Default is 1280.
    • HEIGHT: Display height. Default is 720.
    • GPU: Enables experimental Intel iGPU acceleration. Default is N.
    • RENDERNODE: Render node used for GPU acceleration. Default is /dev/dri/renderD128.

    Web Interface

    • WEB: Enables the web interface. Default is Y.
    • WEB_PORT: Port for the web interface. Default is 8006.
    • VNC_PORT: Port for the VNC server. Default is 5900.
    • AUDIO: Streams guest audio to the web viewer. Default is N.
    • SOUND: QEMU audio device used by the web viewer. Default is intel-hda.
    • PROTECT: Enables password protection for the web interface. Default is N.
  9. Share files between host and Windows

    master

    To exchange files, bind a host folder to /shared in your compose file. This folder will appear inside Windows as the Shared folder on the desktop and as the Z: drive.

    volumes:
      - ./example:/shared
  10. Set Windows language and keyboard layout

    master

    Specify the installation language and the keyboard/region settings using LANGUAGE, KEYBOARD, and REGION environment variables.

    environment:
      LANGUAGE: "French"
      REGION: "en-US"
      KEYBOARD: "en-US"
  11. Configure Storage and Disk settings

    master

    Manage how the virtual disk is created and stored:

    • DISK_SIZE: Size of the primary disk (e.g., 64G). Default is 64G.
    • DISK_FMT: Disk image format (raw or qcow2). Default is raw.
    • DISK_TYPE: Disk device type (sata, scsi, nvme, or blk). Default is scsi.
    • DISK_CACHE: Disk cache mode (none or writeback). Default is none.
    • DISK_IO: Disk I/O mode (native, threads, or io_uring). Default is native.
    • DISK_DISCARD: Discard/TRIM mode for the primary disk. Default is unmap.
    • DISK_ROTATION: Rotation rate (use 1 to identify as an SSD). Default is 1.
    • DISK_FLAGS: Additional options for qcow2 disks.
    • DISK_OPTIONS: Additional options appended to QEMU disk devices.
    • ALLOCATE: Preallocates space for the primary disk. Default is N.
    • STORAGE: Directory used for disks, firmware, and downloads. Default is /storage.
  12. Configure user credentials and Active Directory

    master

    Set custom login credentials or join an Active Directory domain during installation using environment variables.

    environment:
      USERNAME: "bill"
      PASSWORD: "gates"
      DOMAIN: "example.com"
      DOMAIN_OU: "OU=Virtual Machines,OU=Servers,DC=example,DC=com"