Install Docker on Windows Server 2016 using DSC
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.
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
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 the LCM meta configuration that sets Push Mode , allows the LCM to reboot the node if required and configures ApplyAndAutoCorrect mode. 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.
本文系统（windows）相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术
本文标题：Install Docker on Windows Server 2016 using DSC