Windows Server 2016 is now GA and it contains some pretty exciting stuff. Chief among them for me is support for containers by way of Docker. So, one of the first things I did was start installing Windows Server 2016 VM’s (Server Core and Nano Server naturally) and installing Docker on them so I could begin experimenting with Docker Swarms and other cool stuff.

Edit: If you’re looking for a DSC configuration for setting up Docker on a Windows 10 Anniversary Edition machine, see the Windows 10 AE section below.

At first I started using the standard manual instructions provided by Docker, but this doesn’t really suit any kind of automation or infrastructure as code methodology. This of course was a good job for PowerShell Desired State Configuration (DSC).

So, what I did was put together a basic DSC config that I could load into a DSC Pull Server and build out lots of Docker nodes quickly and easily. This worked really nicely for me to build out lots of Windows Server 2016 Container hosts in very short order:

If you don’t have a DSC Pull server or you just want a simple script that you can use to quickly configure a Windows Server 2016 (Core or Core with GUI only) then read on.

Note: This script and process is really just an example of how you can configure Docker Container hosts with DSC. In a real production environment you would probably want to use a DSC Pull Server.

Get it Done

Edit: After a suggestion from Michael Friis (@friism) I have uploaded the script to the PowerShell Gallery and provided a simplified method of installation. The steps could be simplified even further into a single line, but I’ve kept them separate to show the process.



Using PowerShell Gallery

On a Windows Server 2016 Server Core or Windows Server 2016 Server Core with GUI server:

Log on as a user with Local Administrator privileges. Start an Administrator PowerShell console – if you’re using Server Core just enter PowerShell at the command prompt: Install the Install-DockerOnWS2016UsingDSC.ps1 script from the PowerShell Gallery using this command:



You may be asked to confirm installation of these modules, answer yes to any confirmations.

Run the Install-DockerOnWS2016UsingDSC.ps1 script using:





The script will run and reboot the server once. Not long after the reboot the Docker service will start up and you can get working with containers:

You’re now ready to start working with Containers.

The Older Method (without PowerShell Gallery)

On a Windows Server 2016 Server Core or Windows Server 2016 Server Core with GUI server:

Log on as a user with Local Administrator privileges. Start an Administrator PowerShell console – if you’re using Server Core just enter PowerShell at the command prompt: Install the DSC Resources required for the DSC configuration by executing these commands:



You may be asked to confirm installation of these modules, answer yes to any confirmations.

Download the Docker installation DSC script by executing this command:



Run the Docker installation DSC script by executing this command:





The script will run and reboot the server once. Not long after the reboot the Docker service will start up and you can get working with containers:

You’re now ready to start working with Containers.

What the Script Does

In case you’re interested in what the script actually contains, here are the components:

Configuration ContainerHostDsc – the DSC configuration that configures the node as a Docker Container host. Configuration ConfigureLCM Push Mode, allows the LCM to reboot the node if required and configures ApplyAndAutoCorrect mode.

– the LCM meta configuration that sets, allows the LCM to reboot the node if required and configuresmode. ConfigData – a ConfigData object that contains the list of node names to apply this DSC Configuration to – in this case LocalHost. ConfigureLCM – the call to the Configuration ConfigureLCM to compile the LCM meta configuration MOF file. Set-DscLocalConfigurationManager – this applies the compiled LCM meta configuration MOF file to LocalHost to configure the LCM.

ContainerHostDsc – the call to the Configuration ContainerHostDsc to compile the DSC MOF file. Start-DSCConfiguration – this command starts the LCM applying the DSC MOF file produces by the ContainerHostDsc.

The complete script can be found here. Feel free to use this code in anyway that makes sense to you.

What About Windows 10 AE?

If you’re looking for a DSC configuration that does the same thing for Windows 10 Anniversary edition, Ben Gelens (@bgelens) has written an awesome DSC config that will do the trick. Check it out here.

Happy containering!