Launching a Virtual Machine inside a Docker container.
- Non libvirt dependant.
- It uses QEMU/KVM to launch the VM directly with PID 1.
- Support GPU passthrough by Intel GVT-d.
- Match mouse and keyboard device automatically.
- It attaches to the VM as many NICs as the docker container has.
- The VM gets the original container IPs.
- Uses macvtap tun devices for best network throughput.
- Outputs serial console to stdio, thus visible using docker logs
Partially based on BBVA/kvm project.
- Ubuntu 18.04 has been fully validated as host, other Linux operating system like RHEL/Debian with 4.X+ kernel is also OK.
Fully validated list:
- Windows 10
- Ubuntu 18.04
- Debian 9
For client platforms, 5th, 6th or 7th Generation Intel® Core Processor Graphics is required. For server platforms, E3_v4, E3_v5 or E3_v6 Xeon Processor Graphics is required.
- GVTd setup on host.
- (Optional)Virtual network deployed(ipv6 should be disabled if you choose Calico network due to this issue)
git clone https://github.com/China-HPC/docker-kvm
cd docker-kvm
build -t docker-kvm .
Prepare a qcow2 empty disk file name as disk.qcow2, put the ISO image and drivers iso(optional) in the same directory, then run:
docker run --rm -e OS_ISO='/kvm/cn_windows_10_multiple_editions_x64_dvd_6848463.iso' -e DRV_ISO='/kvm/drv.iso' -e RAM=6G -v /dev:/dev -v /sys:/sys --privileged -v /opt/kvm/win10:/kvm --name kvm-test docker-kvm
The supported options list in the Dockerfile, specify them with -e $VAR=$VAL