Using Docker with Hyper-V: the easy way

Docker is pretty cool, but there’s one thing that always gets in the way for me.

The default installer sucks.

Installing Docker using the Windows version of the Docker Toolkit means it installs multiple things on your computer:

  • The Docker command-line tools (hooray)
  • Virtual Box (boo)
  • Kitematic, a user interface (only works with Virtual Box… so also boo?)

As I use Hyper-V as my virtualization platform of choice, Virtual Box is completely redundant. More than that, it’s an annoyance. They’re incompatible with each other.

Obviously this was no good for me, so after a bit of messing around I have found my preferred method for getting Docker up and running on own workstations using Hyper-V.

As is always the case with these things, this may not be the best way for everyone. But if you’re interested, here’s what I did:

Note: the following assumes you have some knowledge of Windows and PowerShell in order to keep the instructions brief.

Setup Hyper-V

  • Ensure you have Windows 8.1 or 10 Professional
  • Ensure you have Hyper-V installed
  • Create an external switch called “External Switch” (if you don’t have one)

Get the binaries

  1. Get docker.exe client from:
  2. Get docker-machine.exe from:
  3. Put them in a new ~\Scripts\Docker folder

Update your PowerShell profile.ps1 file

Make sure you can get to your new commands by using an alias or add the folder to your PATH, either works:

Set-Alias docker            "~\Scripts\Docker\docker.exe"
Set-Alias docker-machine    "~\Scripts\Docker\docker-machine.exe"

And then add some variables to be used by default, like the network switch and memory allocation:

$env:HYPERV_VIRTUAL_SWITCH  = "External Switch"
$env:HYPERV_MEMORY          = 2048

Create and configure your machine

After this you should be able to create a new boot2docker VM on Hyper-V:

PS> docker-machine create -d hyperv default

Once that’s up and running you’ll need to set your environment for the Docker client:

PS> docker-machine env --shell=powershell default | invoke-expression

Try out a container

Working? Great! Try running something, like the new .NET Core container:

PS> docker run -it microsoft/dotnet:latest


Looks like there will be an even easier way to do this moving forward, thanks to an upcoming release of Docker for Windows which will use Hyper-V by default. (Yesssss!!!)

Find out more through this handy article from Scott Hanselman.

Windows Server 2016 for Developers

Windows Server

It’s not often I get excited about new versions of Windows Server. It has been a long time since I have professionally managed any servers or worked in any kind of IT environment. It’s also been a long time since I’ve had my own personal servers at home. At one point, I had five Windows Server 2003 boxes in an Active Directory domain!

As a developer, many of the changes coming in Windows Server 2016 have got me excited.

The things I care most about are servers which power cloud applications, and not the traditional view of a back office server for files and printers – something Windows has traditionally been associated with since the 1990s.

With this in mind, here are the top three technologies I am most interested in as a software development engineer and a solution architect.

1. Nested Virtualisation

Nested Virtualisation

Virtualisation has always been something I have been keen on, and Microsoft’s main platform for this is Hyper-V, a powerful server-based virtualisation platform which works on the client, server, and cloud.

Because Hyper-V uses a hypervisor to directly access virtualisation-enabled hardware, there has always been a limitation stopping you from running hypervisor based virtualisation inside a machine which is already virtualised. With the latest version of Hyper-V shipping with Windows Server 2016 (and Windows 10) you can actually nest these hypervisors inside each other – essentially letting you run a virtual machine inside a virtual machine.

I use a virtual machine hosted on Azure as a developer platform, so the ability to use virtualisation technologies (including Windows and Android emulators) inside of that virtual machine would be very handy. At the moment I have to run these tools locally on my physical hardware.

Currently, virtual machines need to be manually tweaked to enable the nested virtualisation – so we’re not quite at the stage where it is completely seamless, but being able to run a Windows 10 Mobile emulator inside of a Windows 10 desktop virtual machine running inside of Windows Server doesn’t seem too far fetched.

2. Containers

Windows Containers

Container technology is similar to virtualisation, but rather than having the overhead of virtualising the whole machine, applications can be sandboxed into their own execution environment while continuing to share system resources, like the file system.

This means these sandboxed applications can be started much faster and the overheads are smaller, allowing much higher density.

Windows Server 2016 brings container technology to Windows applications and also allows an extra level of separation by offering Hyper-V containers as well.

You can see why nested virtualisation is important.

Containers aren’t new, Linux has had support for containers for a while now, and the recent popularity of Docker has made this technology a fantastic option for developers to design their applications to work inside these containers, and then share them on Docker Hub.

Microsoft recently announced a partnership with Docker and you can find plenty of material from the folks in Redmond showing how the Docker tools work with Windows containers. It’s important that Microsoft get this right, as they don’t want to miss out on this important change in the way developers build and ship solutions.

With the ability to have a full VM separation running in Hyper-V containers, it’s quite possible that Linux could run on top of the Windows Server container system. A single management interface to run mixed containers? Sign me up.

For this to really take off, developers would need to be able to do this on their own machines. Right now Docker on Windows is a pain if you use Hyper-V as it’s incompatible with the current version of the Docker Toolbox. Microsoft have to be trying to fix this with their partnership and it’s likely ‘Barcelona‘ is part of this.

Windows is most certainly my platform of choice for the desktop, but I want the applications I create to be cross platform. Being able to create Linux containers using the same management tools as Windows containers is a must.

3. Nano Server

Nano Server

When trying to increase the density if your containers, you want your operating system to be as compact as possible. Windows Server has always been quite a bit larger than Linux when used in its smallest configuration.

Nano Server is a new, highly cut-down version of Windows specifically designed for virtualisation, containers, and cloud environments. Nano Server’s new reduced feature set is a minimum bar to which Windows containers can target – anything that runs on the Nano SKU can run on the Core SKU and above too. But this new minimum bar cuts out many features which are unnecessary, including any UI. If you want to do anything on Nano Server you need to use PowerShell or SSH. (PowerShell Direct is an awesome new feature which will ensure you can connect to a virtualised Nano Server even when it’s not connected to the TCP/IP network – very cool)

Out of the box, Microsoft claims that Nano Server will have over 90% smaller VHD footprint and 80% fewer reboots than the current Windows Server. That’s a big improvement for both Hyper-V hosts and guests.

Roles like IIS can be already be added to Nano Server and Microsoft’s Tools for Docker already helps you write ASP.NET, Node.js, or any other kind of application and directly target a Nano Server container. The tools are great for publishing, and remote debugging is supported, just as you’d expect.

Running a Nano Server in a Hyper-V container like this means the overhead on the developer’s machine is smaller, but it’s still running the real environment just as you’d get in production. Need a special version of a framework for a project? No problem – it’s a container running inside Nano Server which you can spin up as required. This makes me think that all three of these technologies born in Windows Server 2016 must be coming to Windows 10. You can’t expect a developer to run Windows Server 2016 on their Surface!

One Last Thing…

There is one part of this release which is bothering me.

Why call it Windows Server 2016?

I think the trend of having these year-based names must come to an end, It just doesn’t make sense anymore. I’d much rather see Microsoft brand the platform as Windows Server 10 or something similar. Think of how companies like Ubuntu brands their server versions: 14.04 LTS, 14.10, 15.04, 15.10 etc. (LTS stands for Long Term Support, something Microsoft is now doing for their Windows 10 Enterprise customers.)

Currently, Nano Server skips all of this branding in Microsoft’s documentation. I don’t know if that’s just because it’s in preview, but I hope it’s a sign of changes to come. Recently, Microsoft decided to drop year-based naming from their Dynamics AX ERP product, I think they should do this for Windows Server too.

For me, the details are important. In a world where Microsoft is finally embracing new thinking, I feel this year-based branding is a tradition that should let go.

Keep in mind it’s December 2015 and the current version of Windows Server is called “Windows Server 2012 R2 with Update” – seriously.

Windows Server 2016 is due to ship in late 2016.