Docker for Windows: installation

What is Docker for Windows and how do you live with it?

Put very simply, Docker is a way to run an application in a sandbox where the application thinks nothing else is installed on the computer. Docker appeared in the Linux world, became popular, and after a while the Windows world wanted a toy like that too. It's used for web and console applications.

This post is for those who are far from the Linux world, who are interested in Docker for Windows, and who for some reason still haven't dug into the topic.

Docker only arrived on Windows Server with Windows Server 2016. It arrived in an extremely raw state. It could do almost nothing and was good mainly for "having a look at the overseas marvel". Later came Windows Server version 1709, then 1803. All this time Docker kept growing. It grew and grew, and finally Windows Server 2019 and Windows Server version 1809 came out. Docker has grown up. Of course, it still can't do a lot of what we'd like, but what's already there is enough for a production-ready solution.

Preparing for installation

Docker can be installed on both a client OS and a server OS. Below I mean Windows 10 1809 and Windows Server 1809. Docker requires the Containers system feature to be installed first. On Windows 10 you also need to install Hyper-V. On Windows Server this step isn't mandatory, but it is advisable.

Installation

Since Docker keeps evolving and something in it is constantly being improved, I prefer to use the nightly builds on both Windows 10 and Windows Server. That said, I can't recommend this approach to everyone.

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy
    {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem)
        {
            return true;
        }
    }
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

Write-Host "Download packages..."
Invoke-WebRequest -Uri https://master.dockerproject.com/windows/x86_64/docker.zip -OutFile "$env:TEMP\docker.zip"
Write-Host "Update Docker Engine..."
Expand-Archive -Path "$env:TEMP\docker.zip" -DestinationPath "C:\Program Files\." -Force
[System.Environment]::SetEnvironmentVariable("PATH", "$env:PATH;C:\Program Files\Docker", "Machine")
Set-Location "C:\Program Files\Docker"
.\dockerd.exe --experimental --register-service

Write-Host "Restarting..."
Restart-Computer

Checking that it works

To check that the service is installed and running, run this command in a terminal:

docker version

and you'll get something like this

Client:
 Version:           master-dockerproject-2018-11-26
 API version:       1.40
 Go version:        go1.11.1
 Git commit:        2d692aed
 Built:             Mon Nov 26 23:50:37 2018
 OS/Arch:           windows/amd64
 Experimental:      false

Server:
 Engine:
  Version:          master-dockerproject-2018-11-26
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.11.2
  Git commit:       ed37f60
  Built:            Mon Nov 26 23:59:05 2018
  OS/Arch:          windows/amd64
  Experimental:     true

First results

So, we have Windows Server 2019 with Docker installed. Time to start playing around.

Only registered users can leave a comment.

Sign in or register to leave a comment.