Last active
          May 31, 2023 05:28 
        
      - 
      
 - 
        
Save mustafaakin/0cfbc1b4bb346a05a615 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
mustafaakin revised this gist
Aug 22, 2015 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Are you let down when you saw there is no guide to use Windows Server 2016 under ``` $ 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 ``` ## 2. Downloading files @@ -21,6 +21,8 @@ $ // outputs windowsserver_en-us_tp3_container_vhd.vhd ### NSSM: (Non Sucking Service Manager) 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 @@ -32,7 +34,7 @@ You have to type this file, it is in the gist. If you want, you can modify the p ## 3. Modifiyng the VM Image 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 @@ -67,7 +69,7 @@ $ qemu-img convert -f qcow2 -O vdi container_host.qcow2 container_host.vdi ``` 1. New 2. Name whatever you like 3. Type: Microsoft Windows, Version: Windows 2012 (64 bit) 4. Memory: Be generous, at least 2GB 5. Use an existing virtual drive @@ -86,11 +88,14 @@ 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. ### 6. Running Docker commands in Windows You will see the following as a result:  Happy containerizing! *Mustafa Akın* **mustafa91 at gmail**  - 
        
mustafaakin revised this gist
Aug 22, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,6 +88,7 @@ It will ask you to type DockerPath. And you need to write ```http://aka.ms/Conta You will see the following as a result:  Happy containerizing!  - 
        
mustafaakin revised this gist
Aug 22, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. - 
        
mustafaakin revised this gist
Aug 22, 2015 . 2 changed files with 101 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ $ wget http://nssm.cc/release/nssm-2.24.zip $ unzip nssm-2.24.zip ``` ### unattend.xml You have to type this file, it is in the gist. If you want, you can modify the password (beware, 2 instances). @@ -38,8 +38,9 @@ First, we convert VHD image to QCOW2 format. Beware it takes a lot of time, even $ 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/ ``` ## 4. Creating a new VM @@ -58,7 +59,37 @@ You have to create a new virtual machine, you can do it with VirtManager or Virt 9. Finish ### virtualbox 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 ``` 1. New 2. <Name whatever you like> 3. Type: Microsoft Windows, Version: Windows 2012 (64 bit) 4. Memory: Be generous, at least 2GB 5. Use an existing virtual drive 6. Browse icon, find the *vdi* image we had 7. Finish (optionally change CPU count from settings to run it faster) ## 5. Running the VM 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 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ <?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> <servicing></servicing> <settings pass="generalize"> <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls> <DoNotCleanUpNonPresentDevices>true</DoNotCleanUpNonPresentDevices> </component> <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SkipRearm>1</SkipRearm> </component> </settings>" <settings pass="specialize"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <AutoLogon> <Password> <Value>MustafaMustafa91</Value> <PlainText>true</PlainText> </Password> <Enabled>true</Enabled> <LogonCount>999</LogonCount> <Username>Administrator</Username> </AutoLogon> <ComputerName>*</ComputerName> </component> <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <fDenyTSConnections>false</fDenyTSConnections> </component> <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <UserAuthentication>0</UserAuthentication> </component> <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <FirewallGroups> <FirewallGroup wcm:action="add" wcm:keyValue="RemoteDesktop"> <Active>true</Active> <Profile>all</Profile> <Group>@FirewallAPI.dll,-28752</Group> </FirewallGroup> </FirewallGroups> </component> </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <OOBE> <HideEULAPage>true</HideEULAPage> <HideLocalAccountScreen>true</HideLocalAccountScreen> <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> <NetworkLocation>Work</NetworkLocation> <ProtectYourPC>1</ProtectYourPC> </OOBE> <UserAccounts> <AdministratorPassword> <Value>MustafaMustafa91</Value> <PlainText>True</PlainText> </AdministratorPassword> </UserAccounts> </component> <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <InputLocale>en-us</InputLocale> <SystemLocale>en-us</SystemLocale> <UILanguage>en-us</UILanguage> <UILanguageFallback>en-us</UILanguageFallback> <UserLocale>en-us</UserLocale> </component> </settings> </unattend>  - 
        
mustafaakin created this gist
Aug 22, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ 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. ## 1. Getting the required tools: ``` $ sudo apt-get install qemu-kvm virt-manager // or virtualbox, but we need qemu-kvm for image manipulation $ sudo apt-get install libguestfs-tools // image manipulation tools ``` ## 2. Downloading files ### WS2016 TP3 VHD image 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 ``` ### NSSM: (Non Sucking Service Manager) ``` $ wget http://nssm.cc/release/nssm-2.24.zip $ unzip nssm-2.24.zip ``` ### attend.xml You have to type this file, it is in the gist. If you want, you can modify the password (beware, 2 instances). ## 3. Modifiyng the VM Image 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 re ``` $ 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 attend.xml mnt/ $ suco cp nssm-2.24/win64/nssm.exe mnt/Windows/System32/ ``` ## 4. Creating a new VM You have to create a new virtual machine, you can do it with VirtManager or VirtualBox. ### virt-manager 1. Create a new Virtual Machine 2. Import existing disk image, Forward 3. Provide existing storage path, Browse 4. Browse Local 5. Find ws2016_core.qcow2, and Open 6. OS Type: Windows 7. Version: Microsoft Windows Server 2008 or later 8. Adjust memory and RAM (give as much as you can) 9. Finish ### virtualbox // Coming soon ## 5. Executing required commands in VM