Containers are a hot topic in the software industry at the moment. The technology promises rapid development and deployment of web-scale applications. Although much of the interest is focused on Linux containers, the concept has been adopted by other operating systems, with Windows Server 2016 being the latest to join the party.
Earlier this year, Microsoft started to include container support in its Windows Server 2016 Technical Previews. Additionally, the company worked with Docker to integrate Windows containers into the core Docker container development, deployment, management and run-time stack.
XenServer is already embracing Docker Linux containers by integrating with the Docker stack to provide administrators with visibility, reporting and control of Docker container-hosting environments. This capability is extended to Windows containers in XenServer 7.0, released this week.
Before we look at how to set up Windows containers and use the XenServer Docker integration let’s take a quick look at some of the benefits of the integration:
Monitoring and visibility – knowing which VMs are in use for Docker hosting and which containers on them are actually running. Today’s interface is more of a “pets” than “cattle” one but it’s fine for small to medium scale deployments and evaluations.
Diagnostics – easy access to basic container information such as forwarded network ports and originating Docker image name. This can help accelerate investigations into problems where either or both of the infrastructure and application layers may be implicated.
Runtime management – using XenCenter you can start, stop and pause application containers. This feature has a number of use cases in both evaluation and deployment scenarios including rapidly terminating problematic applications
Let’s start by getting a XenServer 7.0 environment – we don’t need anything special here so I’ll use my favorite demo platform, an Intel NUC NUC5i5RYH installed with XenServer 7.0 using a local SSD. XenServer’s Docker integration is delivered as a supplemental pack (XenServer’s add-on format). We can use XenCenter’s update wizard (“Tools” menu, “Install Update…”) to apply the pack. Browse to find the supplemental pack (it’s an ISO file) and follow the wizard through.
We can now go ahead and install a Windows Server 2016 Technical Preview VM. I’m going to use Technical Preview 5 (TP5) for this demo. I’ve already set up an ISO storage repository and this contains the TP5 ISO. We can install the VM in the usual manner; for this demo let’s use 4GB of memory and 2 vCPUs. The installer offers the option of installing with or without a “Desktop Experience” – it’ll be easier to play with this with a proper UI so let’s select that. When the Windows installer asks to choose an install type we need to select “Custom: Install Windows only” because we don’t already have an existing Windows installation in our VM.
Once the Windows installation has completed we can install the XenServer Tools (agent and device drivers) in the normal manner – you may notice that this is a quicker and easier process compared to earlier XenServer versions.
So now we have a Windows Server 2016 TP5 VM all set up and ready to go. We’ll now set this VM up for running Docker containers. Microsoft have provided documentation and tools to make this easy (if you’ve previously tried this on earlier Server 2016 Tech Previews then you may be pleasantly surprised by the improvements with the TP5 tooling). We’ll follow the instructions on the MSDN containers microsite – specifically the “Scripted – Existing System” instructions.
Using PowerShell we’ll fetch the install script and then run it, omitting the “-HyperV” option because we’re going to use Windows Server Containers, not Hyper-V Containers.
wget -uri https://aka.ms/tp5/Install-ContainerHost -OutFile C:\Install-ContainerHost.ps1
powershell.exe -NoProfile -ExecutionPolicy Bypass C:\Install-ContainerHost.ps1
The install script will reboot the VM and continue running once we’ve logged back in to the desktop. The install takes a few minutes because it has to download and process the Windows Server Core container base image.
Once this installation has finished we have a working Windows container environment and Docker stack. The next step is to enable the VM for XenServer’s container management. This is similar in concept to the mechanism used for Linux Docker VMs however for Windows we use TLS connections to the Docker daemon instead of tunneling over SSH as in the Linux case. To set this up we can use the host’s console to query the VM’s UUID and run the prepare script. We have the option of providing our own TLS certificates however in this case we’ll have the script generate its own self-signed certificates.
The script will automatically create a CD image (ISO) containing the certificates to be added to the Windows Server 2016 VM and a script to install them; it will then prompt us to switch back to the VM to run this script.
Having switched back to the host console and let it complete the setup script we now have a configured VM ready for use. We can check the integration is working by looking for the “Docker Information” section of the VM’s “General” tab.
A good way to try out Windows containers via Docker is to follow the IIS example on the MSDN containers microsite. This example shows how to create and modify containers, firstly by creating an image containing the IIS web server, and then creating containers based on this image. We can enhance this example by running multiple IIS containers on the same host on different TCP ports. To do this we modify the port mapping in the “docker run” commands, e.g.:
docker run --name iisdemo81 -i -t -p 81:80 windowsservercoreiis cmd
docker run --name iisdemo82 -i -t -p 82:80 windowsservercoreiis cmd
Take a look at the video below to see this in action.
Once we have a few containers running we can see the effect of the XenServer Docker integration. The key items to notice are:
This concludes our demo of Windows Server Containers on XenServer 7.0. I encourage you to try it out for yourself. You can find downloads of XenServer 7.0 and the container management pack at https://www.citrix.com/products/xenserver/overview.html and Windows Server 2016 TP5 at https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-technical-preview