In previous blog post, we discussed what are windows containers, how they are different from Hyper-V containers and how they are beneficial to developers and sysadmins. We also discussed how Docker as a company has played an important part in the story. In this blog post, we will get quickly get started with installing windows containers and run our first container image by pulling it from docker registry.
- You must have a machine with Windows Server 2016 or Windows 10 installed on it. It may be a physical machine or the virtual machine. On the Sku side, you can have either DataCenter version or Standard version as well. Or you may also use Windows Server Core version.
- If its a virtual machine, make sure it has nested virtualization enabled.
- All windows updates should be installed on the machine.
- Administrative access to the machine.
Install Windows Container Feature
We’ll get started by installing the Windows Containers feature on the container host by running below command:
Install-WindowsFeature -Name Containers
After this, we need to restart the computer. For this, we can use below command:
We can also check if windows feature for containers got installed properly by using below command:
Get-WindowsFeature -Name Containers
Install Docker Engine
Since container functionality is essentially provide by Docker, we need to install the Docker Engine. To achieve this goal, we have two options. The first one is to install it using PowerShell Module feature:
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
However, Microsoft has declared this as deprecated method. The new method is to install docker using the REST API interface provided by docker itself. This allows one to download the latest version, in order to get all new features.
This can simply be done by using below command:
Invoke-webrequest -UseBasicparsing -Outfile docker-17.06.2-ee-11.zip https://download.docker.com/components/engine/windows-server/17.06/docker-17.06.2-ee-11.zip
Now, we can extract the zip file using below command:
Expand-Archive docker-17.06.2-ee-11.zip -DestinationPath $Env:ProgramFiles
Now, we’ll add docker binary path to current session and also to the list of environment variables:
$env:path += “;$env:ProgramFiles\docker”
$newPath = “$env:ProgramFiles\docker;” + [Environment]::GetEnvironmentVariable(“PATH”,
Finally, we need to register the Docker daemon as a service by using below command:
We also need to start docker service by using below command:
Verifying Docker is Working
We can run docker info command to verify if we have installed it successfully. You should get an output like below:
We can also deploy our first Windows container! For the first example, we will deploy a hello-world container:
When you run the command, Docker checks if the image is available locally (on the container host). If not, then Docker retrieves the image from the Docker hub.