Sitecore running in a Windows Server Container - Part 2
Here you can find some tips and tricks I picked up while playing around with this awesome new Windows feature. You should also read Part 1 before this makes any sense :)
Host VM tweaks
To manage the host from your workstation you can use
Enter-PSSession -VMName "wscdev"
, more about the new PowerShell Direct feature on MSDN.Remove Windows Defender, totally cripples build and running images:
Uninstall-WindowsFeature -Name Windows-Defender-Features -Restart
To set the keyboard language to something else than en-US:
Set-WinUserLanguageList -LanguageList da-DK
Place the VHD on SSD for maximum disk performance, most image/container operations are very disk I/O hungry.
Soon you will run out of disks space in the host VM (is 20 GB). Here is how to make a larger host with more space:
- Copy
ServerDatacenterCore_en-us_TP4_Container.vhd
toServerDatacenterCore_en-us_TP4_Container_Extended.vhd
. - Use the "Edit disk" feature in Hyper-V to expand it.
- Double-click the new expanded VHD to mount it.
- Use "Disk Management" to re-size the OS volume.
- Use "Explorer" to eject the mounted VHD.
- Use VhdPath parameter of New-ContainerHost.ps1 to reference the expanded VHD.
Connecting with the host VM from your workstation
On the host add " -H 0.0.0.0:2375" right after the first occurrence of "-b "Virtual Switch" and before the "goto" in the file "c:\ProgramData\docker\runDockerDaemon.cmd"
Run
net stop docker
andnet start docker
to restart the Docker daemonOpen the new port with:
New-NetFirewallRule -Name "TCP2375" -DisplayName "TCP2375" -Protocol tcp -LocalPort 2375 -Action Allow -Enabled True
Now set the DOCKER_HOST environment variable to your host VM IP:
$env:DOCKER_HOST = "tcp://10.20.34.227:2375"
You can now use docker.exe
from you workstation!
Cleaning up
Delete all stopped containers:
docker rm $(docker ps -a -q)
Delete all tagged images tagged with "none":
docker rmi $(docker images -q -f dangling=true)
Other stuff
- Modifying NTFS permissions in containers does not work - Everything must run as LocalSystem...
- Please go vote on Native container support on Windows 10 so we can run containers without an extra host VM layer.