Skip to content

Docker on Windows

Christoph Diehl edited this page Jan 23, 2019 · 9 revisions

Docker on Windows

NOTE: Skip the next two steps if you plan to run Windows native containers without Hyper-V and your Windows 10 version is >=1809. If the update is not yet reachable through Windows Update Media Creation Tool 2019 to perform the Upgrade.

Validate Hyper-V and Containers Windows 10 Features are Enabled

"Microsoft-Hyper-V","Containers" | `
    ForEach-Object { `
        Get-WindowsOptionalFeature `
            -FeatureName $_ `
            -Online ;
    } ;

Install Hyper-V and Containers Windows 10 Features

Enable-WindowsOptionalFeature `
    -FeatureName "Microsoft-Hyper-V", "Containers" `
    -Online `
    -All `
    -NoRestart ;

Download and Install Docker

This will download the latest stable version, alternative you can download and install the Edge release by replacing the download URL.

Invoke-WebRequest `
    -UseBasicParsing `
    -Uri "https://download.docker.com/win/stable/Docker%20for%20Windows%20Installer.exe" `
    -OutFile "$Env:TEMP\DockerForWindowsInstaller.exe" ;
Start-Process `
    -FilePath "$Env:TEMP\DockerForWindowsInstaller.exe" `
    -ArgumentList "install", "--quiet" `
    -Wait ;

Reboot

Restart-Computer

Switch Docker Daemon

By default Docker on Windows is configured to run LCOW, in order to run Windows native containers we need to switch the Docker Daemon. Verify for which OS the Docker Daemon is configured.

PS C:\Users\posidron> docker version
Client: Docker Engine - Community
 Version:           18.09.1
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        4c52b90
 Built:             Wed Jan  9 19:34:26 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       4c52b90
  Built:            Wed Jan  9 19:41:49 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Server: OS/Arch says linux/amd64

& $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon
docker version

The output should now show windows/amd64 for the Docker Server. It is possible to set the Docker Daemon explicitly instead of using the -SwitchDaemon parameter.

-SwitchLinuxEngine
-SwitchWindowsEngine

NOTE: If you performed this step because you wanted to run native Windows containers without Hyper-V then you need to enable Hyper-V first to switch to the Linux Engine.

Run Mircosoft NanoServer

docker run -it microsoft/nanoserver cmd

If you run Windows 10 with a version >= 1809 you must use process isolation for building and running the container. It is also required that the host Windows version must match the Windows version running in the client container.

docker run --isolation=process -it mcr.microsoft.com/windows/nanoserver:1809

Recommendation

Add "experimental": true to %programdata%\docker\config\daemon.json