Sitecore Running in a Windows Server Container - Part 2

Senior Sitecore Developer
Valtech DK

December 18, 2015

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:

  1. Copy ServerDatacenterCore_en-us_TP4_Container.vhd to ServerDatacenterCore_en-us_TP4_Container_Extended.vhd.
  2. Use the "Edit disk" feature in Hyper-V to expand it.
  3. Double-click the new expanded VHD to mount it.
  4. Use "Disk Management" to re-size the OS volume.
  5. Use "Explorer" to eject the mounted VHD.
  6. Use VhdPath parameter of New-ContainerHost.ps1 to reference the expanded VHD.

Connecting with the host VM from your workstation

  1. On the host add " -H" right after the first occurrence of "-b "Virtual Switch" and before the "goto" in the file "c:\ProgramData\docker\runDockerDaemon.cmd"

  2. Run net stop docker and net start docker to restart the Docker daemon

  3. Open the new port with: New-NetFirewallRule -Name "TCP2375" -DisplayName "TCP2375" -Protocol tcp -LocalPort 2375 -Action Allow -Enabled True

  4. Now set the DOCKER_HOST environment variable to your host VM IP: $env:DOCKER_HOST = "tcp://"

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


Original article posted on Invoke Command Blog: Running in a Windows Server Container 

Meet The Challenges Of Today's Digital Economy

Ready to take that first step and rise to your digital potential? Contact Valtech today.
Talk to us