You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A docker container to run a command in Windows 11 (via QEMU). On first run it will generate a Windows 11 ISO and run a VM to install it and create a system snapshot. On subsequent runs it will use the existing cached VM image.
3
+
A docker container to run Windows commands and processes. On first run it will generate a Windows 11 ISO and run a VM to install it and create a system snapshot. On subsequent runs it will use the existing cached VM image.
4
4
5
5
## Usage
6
6
7
7
```bash
8
8
docker run -it --rm --device=/dev/kvm -v $(pwd)/cache:/cache ghcr.io/lg/osrun 'dir c:\windows\system32'
9
9
```
10
10
11
+
```text
12
+
Usage: osrun [-v] [-h] <command>
13
+
Short-lived containerized Windows instances
14
+
15
+
-h --help: Display this help
16
+
-v --verbose: Verbose mode
17
+
18
+
Install
19
+
-k --keep: Keep the installation cached artifacts after successful provisioning
20
+
21
+
Run
22
+
-p --pause: Do not close the VM after the command finishes
23
+
```
24
+
11
25
If you don't have kvm on your machine, you can skip the parameter, but things will be a lot slower. This mode is currently unreliable and may freeze during Windows 11 installation.
12
26
13
27
## Details
14
28
15
-
This container uses [QEMU](https://www.qemu.org/) to run a Windows 11 VM. Windows 11 is built with the file list from [UUP dump](https://uupdump.net/) and files are downloaded directly from Microsoft's Windows Update servers. The UUP dump script generates a Windows ISO which we then inject [virtio drivers](https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html) into along with an `autounattend.xml` script and a variety of Powershell scripts to automate the installation. To keep the VM small and fast we remove a lot of the default Windows components and services including Windows Defender, Windows Update, most default apps, and also disable things like paging, sleep and hibernation, plus the hard drive is compressed and trimmed to be <10GB. This image and VM state is then snapshotted and saved to a cache directory so that subsequent runs can use the cached VM state to startup quickly.
29
+
This container uses [QEMU](https://www.qemu.org/) to run a Windows 11 VM. Windows 11 is built with the file list from [UUP dump](https://uupdump.net/) and files are downloaded directly from Microsoft's Windows Update servers. The UUP dump script generates a Windows ISO which we then inject an `autounattend.xml` script to start the installation automation. To keep the resultant VM small and fast we remove a lot of the default Windows components and services including Windows Defender, Windows Update, most default apps, and also disable things like paging, sleep and hibernation, plus the hard drive is compressed and trimmed to be <10GB. This image and VM state is then snapshotted and saved to a cache directory so that subsequent runs can use the cached VM state to startup quickly. On a reasonably fast machine the installation process takes about 20 minutes end-to-end and runs take about 3-4 seconds for simple commands like `dir`.
16
30
17
-
Communication between the VM and the host is done via the QEMU Agent and a QEMU-started Samba server (available on the host in `/tmp/qemu-status` or in the container in `\\10.0.2.4\qemu`). During installation and execution, multiple debugging services are started (you'll need to forward these ports using Docker):
31
+
Communication between the VM and the host is done via the QEMU Agent and a QEMU-started Samba server (available in the host container in `/tmp/qemu-status` or in the VM in `\\10.0.2.4\qemu`). During installation and execution, multiple debugging services are started (you'll need to forward these ports using Docker if you want to use them):
18
32
- a QEMU-run VNC server is available on port `5950` (not compatible with Apple Screen Sharing),
19
33
- the QEMU Monitor is available on port `55556` (supported commands are [here](https://qemu-project.gitlab.io/qemu/system/monitor.html)), and
20
34
- the QEMU Agent is available on port `44444` (protocol is [here](https://qemu.readthedocs.io/en/latest/interop/qemu-ga-ref.html)).
echo -e "\033[33;49mKVM acceleration not found. Ensure you're using --device=/dev/kvm with docker. Virtualization will be very slow.\033[0m"> /dev/stderr
53
53
KVM_PARAM=""; CPU_PARAM="-accel tcg"
@@ -140,7 +140,7 @@ if [ ! -e /cache/win11.qcow2 ]; then
140
140
if [ !-e"$STEP_ARTIFACT" ];then
141
141
rm -f /cache/win11-step$STEP-*.qcow2 # remove any previous artifacts for this step
0 commit comments