Repository link: https://github.com/gnh1201/docker-qemu
This repository will be long-term maintained on QEMU 6.1.0 (Released on 24 AUG 2021) because there are third-party projects that depend on this repository.
For Non-native environments
Note: Non-native virtualization does not support KVM acceleration (Do not use --device /dev/kvm
).
ARM
$ touch /hdimages/armhf.qcow2 $ docker run -it --rm \ --name qemu-container-arm \ --user="$(id --user):$(id --group)" \ -v /hdimages/armhf.qcow2:/tmp/hda.qcow2 \ -v /bootimages/initrd-debian11-armhf.gz:/tmp/initrd.gz \ -v /bootimages/vmlinuz-debian11-armhf:/tmp/vmlinuz \ -e QEMU_HDA=/tmp/hda.qcow2 \ -e QEMU_HDA_SIZE=20G \ -e QEMU_CPU=1 \ -e QEMU_RAM=1024 \ -v /cdimages/debian-11.1.0-armhf-netinst.iso:/tmp/debian.iso:ro \ -e QEMU_CDROM=/tmp/debian.iso \ -e QEMU_BOOT='order=d' \ -e QEMU_PORTS='2375 2376' \ -e QEMU_ARCH='arm' \ -e QEMU_MACHINE='virt' \ -e QEMU_KERNEL=/tmp/vmlinuz \ -e QEMU_INITRD=/tmp/initrd.gz \ gnh1201/qemu:6.1
MIPS
$ touch /hdimages/mips64el.qcow2 $ docker run -it --rm \ --name qemu-container-mips64el \ --user="$(id --user):$(id --group)" \ -v /hdimages/mips64el.qcow2:/tmp/hda.qcow2 \ -v /bootimages/debian11-mips64el-malta/initrd.gz:/tmp/initrd.gz \ -v /bootimages/debian11-mips64el-malta/vmlinuz-5.10.0-9-5kc-malta:/tmp/vmlinuz \ -e QEMU_HDA=/tmp/hda.qcow2 \ -e QEMU_HDA_SIZE=20G \ -e QEMU_CPU=1 \ -e QEMU_RAM=1024 \ -v /cdimages/debian-11.1.0-mips64el-netinst.iso:/tmp/debian.iso:ro \ -e QEMU_CDROM=/tmp/debian.iso \ -e QEMU_BOOT='order=d' \ -e QEMU_PORTS='2375 2376' \ -e QEMU_ARCH='mips64el' \ -e QEMU_MACHINE='malta' \ -e QEMU_CPUMODEL='5KEc' \ -e QEMU_KERNEL=/tmp/vmlinuz \ -e QEMU_INITRD=/tmp/initrd.gz \ -e QEMU_APPEND='console=ttyS0' \ gnh1201/qemu:6.1
If ARM or MIPS is selected, vmlinuz
(kernel image) and initrd
are required. Please refer to this article and proceed.
Manually bootloader activation
When using the non-native (e.g. ARM, MIPS) platform, the bootloader must be extracted manually after the installation is completed.
$ qemu-img convert armhf.qcow2 armhf.raw $ sudo mkdir /mnt/tmp $ sudo mount -o loop,offset=$((2048 * 512)) armhf.raw /mnt/tmp $ cd /mnt/tmp/boot
Then, copy the initrd
and vmlinuz
files to an external directory. And load using QEMU_KERNEL
and QEMU_INITRD
variables.
Manually root activation
When using the non-native (e.g. ARM, MIPS) platform, it was confirmed that the settings were not reflected in /etc/passwd
and /etc/shadow
. Please refer to the two links below and set them up manually.
Windows Guest on Docker (Linux Host)
Download and create a combined ISO
Windows 10 Image: https://www.microsoft.com/ko-kr/software-download/windows10 (If you change the user agent to iPhone, you can download the ISO file.)
VirtIO Driver
ImgBurn: https://www.imgburn.com/ (like as below)
Options:
MODE1/2048, UDF, 1.02, Recurse Subdirectories, Include Hidden Files, Include System Files
Bootable Disc: Mark the checkbox
Make Image Bootable
, and set the fields to[image path]\boot\etfsboot.com, 80x86, Microsoft Corporation, 07C0, 8
Extract the two ISO files and combine them into one ISO file. (e.g. win10_x64_virtio.iso
)
And then, load the drivers - vioscsi\w10\amd64
(SCSI) and NetKVM\w10\amd64
(Network) - when installing Windows 10
Build a Docker file
git clone https://github.com/gnh1201/docker-qemu && cd docker-qemu/6.1 docker build -t gnh1201/qemu:6.1 .
or use Docker Hub
docker pull gnh1201/qemu:6.1
Write the bash file (e.g., win10-virtio.sh
)
#!/bin/bash docker run -it --rm \ --device /dev/kvm \ --name win10-virtio \ --user="$(id --user):$(id --group)" \ -v /home/john/win10-virtio.qcow2:/tmp/hda.qcow2 \ -e QEMU_HDA=/tmp/hda.qcow2 \ -e QEMU_HDA_SIZE=50G \ -e QEMU_CPU=3 \ -e QEMU_RAM=3072 \ -v /cdimages/win10_x64_virtio.iso:/tmp/debian.iso:ro \ -e QEMU_CDROM=/tmp/debian.iso \ -e QEMU_BOOT='order=d' \ -e QEMU_PORTS='2375 2376 3389' \ -e QEMU_ARCH='x86_64' \ gnh1201/qemu:6.1
The example(/home/john/win10-virtio.qcow2
and /cdimages/win10_x64_virtio.iso
) have to replace with your own path.
If you want to allow RDP external access, please add EXPOSE 3389
to the file 6.1/Dockerfile
(Must be rebuilt image)
Run a container
touch /home/john/win10-virtio.qcow2 ./win10-virtio.sh
Find an IP address of the container
docker ps # get the container ID docker inspect <container ID> # get an IP address
Connect to the container via VNC
Reminna: https://remmina.org/
Access the container with a client capable of accessing the VNC protocol.
All done.
Network issue of default repositories
Due to issues in the production environment with decreased speeds on the default APT repository (e.g., insufficient network peering) and firewall issues (e.g., Mismatched Hash), we are operating a separate cache server. The following cache server is proxied through Cloudflare: