Create a docker container running any OS you like.
2.2K
This image is intended as a tool to help in the creation of other docker containers with any operating system you want inside them.
Specifically this container enables the creation of a Virtual Machine which is ready to be hosted on a qemu/kvm (and optionally virt-manager) hypervisor platform. Most likely, the output of this container will then be used as the VM disk image for running whatever Operating System you installed in the first place on the destination hosting platform. That destination platform could be my any-vm-runner docker container, allowing any OS to be hosted as a docker contaier on your linux based docker platform.
To put it another way, this provides the virtual disk image that you can use to host windows (or any other OS) inside a docker container on linux.
Start the container with the following, or something similar:
docker run -d --privileged \
--name any-vm-creator \
--cgroupns host \
--device=/dev/kvm \
--device=/dev/net/tun \
-e MEMORY=4096 \
-e CPU=4 \
-e DISK=100 \
-e OS_VARIANT=win11 \
-e BIOS_TYPE=UEFI \
-v <<FULL-PATH-to-my-favourite-.ISO>>:/guestVM.iso \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
-v any-vm-creator:/guestVMdata \
-p 5910:5910 \
-p 3390:3389 \
--cap-add=NET_ADMIN \
--cap-add=SYS_ADMIN \
gregewing/any-vm-creator:latest
When the container starts, it will automatically create a sparse .qcow2 file inside the any-vm-creator volume defined above. It will then boot from the provided .ISO and begin the install process, installing the the desired operating system into that qcow2 vidtual disk file. You can keep track of progress by connecting a vnc viewer to port 5910 (unless you changed it) and make any install time configurations interactively.
Once you have completed the install, you can shut down the VM and shut down the container. You might want to reboot instead of to install additional tools or software or make customisations to the VM. The .qcow2 file that was created in the any-vm-creator volume will contain the installed operating system and any customisations that you made along the way.
You now have a .qcow2 virtual disk image file that will operate as per any other virtual disk file you may have used in the past in full-fat hypervisors such as HyperV or VMWare. It is portable and will be bootable on any qemu/kvm instance, or as the VM image for an instance of any-vm-runner.
I assume you understand enough about port mappings in docker to set this up how you need it without me having to tell you how to do it. Map the ports you need based on your requirements.
There are three key volumes or bind-mounts used by this container:
-v <<FULL-PATH-to-my-favourite-.ISO>>:/guestVM.iso replace <<FULL-PATH-to-my-favourite-.ISO>> with the path to the ISO file that you want to install from.-v any-vm-creator:/guestVMdata replace -v any-vm-creator with the name of a volume that you created beforehand. If you don't create a volume and provide it here, one will be created for you with the name any-vm-creator.The above docker run command makes use of the following environment variables, which you may want to alter to suit your requirements:
Yes using Legacy BIOS, and specifically no virtio-win.iso cd mounted.
I have created a github repository for this project, please raise any comments, suggestions or issues there.
Content type
Image
Digest
sha256:ee34831f6…
Size
311.2 MB
Last updated
13 days ago
docker pull gregewing/any-vm-creator