Are you let down when you saw there is no guide to use Windows Server 2016 under *nix environments? I really loved Microsoft when I heard they are working on Windows containers, but when this week has arrived, it was sad to see that installation requirements were Windows and HyperV. But actually it is not. You just have to modify the VHD file a bit with nicer tools and execute the already available script in the downloaded VM. I will assume you are running a decent version of Linux and accepted EULA and all the legal stuff that I do not care.
$ sudo apt-get install qemu-kvm virt-manager // or virtualbox, but we need qemu-kvm for image manipulation
$ sudo apt-get install qemu-utils libguestfs-tools // image manipulation tools
Be careful, the VHD image is around 6.3 GB zipped, 13 GB unzipped VHD.
$ wget http://aka.ms/containerhostvhd -O host.zip
$ unzip host.zip
$ // outputs windowsserver_en-us_tp3_container_vhd.vhd
Manages services, does not seem to be an official MS tool but, it was included in the official script.
$ wget http://nssm.cc/release/nssm-2.24.zip
$ unzip nssm-2.24.zip
You have to type this file, it is in the gist. If you want, you can modify the password (beware, 2 instances).
First, we convert VHD image to QCOW2 format. Beware it takes a lot of time, even on an SSD. Then, we mount it using the tools we have. Reason we use sudo is that we mount it through KVM to make it faster and more reliable. Then we need to copy the attend.xml
to C:/
and nssm.exe
to System32
folders.
$ qemu-img convert -f vpc -O qcow2 windowsserver_en-us_tp3_container_vhd.vhd ws2016_core.qcow2
$ mkdir mnt
$ sudo guestmount -a ws2016_core.qcow2 -i mnt
$ sudo cp unattend.xml mnt/
$ suco cp nssm-2.24/win64/nssm.exe mnt/Windows/System32/
$ sudo umount mnt/
You have to create a new virtual machine, you can do it with VirtManager or VirtualBox.
- Create a new Virtual Machine
- Import existing disk image, Forward
- Provide existing storage path, Browse
- Browse Local
- Find ws2016_core.qcow2, and Open
- OS Type: Windows
- Version: Microsoft Windows Server 2008 or later
- Adjust memory and RAM (give as much as you can)
- Finish
My VirtualBox did not support the qcow2 image I had, we may need to convert it to VDI (virtual disk image) so it plays with it nicer. You can do it via:
$ qemu-img convert -f qcow2 -O vdi container_host.qcow2 container_host.vdi
- New
- Name whatever you like
- Type: Microsoft Windows, Version: Windows 2012 (64 bit)
- Memory: Be generous, at least 2GB
- Use an existing virtual drive
- Browse icon, find the vdi image we had
- Finish (optionally change CPU count from settings to run it faster)
When you run VM via virt-manager or virtualbox, you will see some Windows logo and then you will see a command window. Maximize it and execute the powershell, and execute the already available script we have. I know this could be automated with unattend.xml, but I am no MS expert
C:\Users\Administrator> powershell
PS C:\Users\Administrator> cd /
PS C:\> .\Install-ContainerHost.ps1
It will ask you to type DockerPath. And you need to write http://aka.ms/ContainerTools
and it will download docker.exe from web and place it to System32 folder.
You will see the following as a result:
Happy containerizing!
Mustafa Akın mustafa91 at gmail
typo:
> 3. Modifiyng the VM Image
>..
> $ suco cp nssm-2.24/win64/nssm.exe mnt/Windows/System32/