Installing the Container Feature
As previously mentioned, the container feature is the first feature that is not complete
natively in Windows. Because the container feature relies on the open source Docker,
which is not part of Windows Server and is updated so frequently, it does not make
sense to try to include this feature with Windows. Therefore, to enable containers, I
walk through multiple steps in this section. Over time, however, this process could
change, so if you experience problems, review the Microsoft installation document at
https://msdn.microsoft.com/en-
us/virtualization/windowscontainers/deployment/deployment. If your container host
is a virtual machine and you want to use Hyper-V containers, you need to ensure that
you have enabled nested virtualization for the VM, as outlined at the start of this
chapter.
The first step is to enable the container feature, which can be accomplished via Server
Manager or through PowerShell. This enabling of container functionality provides the
sandboxes that container instances will run in, the container runtime. After the
installation, you need to restart the computer. If you wish to run Hyper-V containers,
you also need to install the Hyper-V role.
Install-WindowsFeature containers
Install-WindowsFeature hyper-v
Restart-Computer -Force
Once the reboot is complete, the next step is to download and install the Docker client
(docker.exe) and the Docker daemon (dockerd.exe), which is the service that other
tools interact with as the management fabric (the Docker Engine). Microsoft
maintains a zip file of both the Docker client and Docker daemon along with docker-
proxy.exe, which provides a caching proxy that is completely transparent to the
Docker containers but will speed up the fetching of any dependencies. The following
code downloads and installs the Docker components:
Invoke-WebRequest "https://get.docker.com/builds/Windows/x86_64/docker-
1.12.0.zip" -OutFile "$env:TEMP\docker-1.12.0.zip" -UseBasicParsing
Expand-Archive -Path "$env:TEMP\docker-1.12.0.zip" `
-DestinationPath $env:ProgramFiles
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program
Files\Docker", [EnvironmentVariableTarget]::Machine)
& $env:ProgramFiles\docker\dockerd.exe --register-service
Start-Service Docker
Note that the preceding code snippet is downloading a specific version, which will
change over time. Thus be sure to refer to the aforementioned Microsoft article to
check for newer versions. It is also possible to pull down each executable directly:
Invoke-WebRequest
https://master.dockerproject.org/windows/amd64/dockerd.exe -OutFile
$env:ProgramFiles\docker\dockerd.exe