Skip to content

Latest commit

 

History

History
190 lines (134 loc) · 6.31 KB

windows-2019-lcow-hyperv.md

File metadata and controls

190 lines (134 loc) · 6.31 KB

Windows Server 2019 LTS + LCOW + HyperV isolation

Nested virtualization support is required to get this solution work.

See options here: nested-virtualization-links.md

Architecture

  • Hyper-V is used to run LinuxKit
  • All the linux containers are executed inside LinuxKit VM
  • Windows containers can be run in both process and hyperv isolation modes

Layout

Windows version selection

LCOW feature is supported from Windows Server 1709 till 2004.

OS Version OS CodeBase Update channel LCOW Support End of support
Windows Server, version 1607 Windows Server 2016 LTS NOPE 01/11/2022
Windows Server, version 1709 Windows Server 2016 SAC LCOW 01/09/2017
Windows Server, version 1803 Windows Server 2016 SAC LCOW 11/10/2020
Windows Server, version 1809 Windows Server 2019 SAC LCOW 11/10/2020
Windows Server, version 1809 Windows Server 2019 LTS LCOW 01/09/2024
Windows Server, version 1903 Windows Server 2019 SAC LCOW 12/08/2020
Windows Server, version 1909 Windows Server 2019 SAC LCOW 05/11/2021
Windows Server, version 2004 Windows Server 2019 SAC WSL2 12/14/2021

Windows Server 2019 (version 1809) Standart\Datacenter is the best choice due to LTS and stability.

See Windows Server release information

Server configuration

Enable Hyper-V components ...

Install-WindowsFeature -Name Hyper-V -IncludeAllSubFeature -IncludeManagementTools
Restart-Computer -Force

Enable Windows Container components. It might be already enabled and then restart is not required.

Install-WindowsFeature Containers
Restart-Computer -Force

Enable docker ...

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$False
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force -Scope AllUsers -Confirm:$False
Install-Package -Name docker -ProviderName DockerMsftProvider -Confirm:$False -Force
Restart-Computer -Force

Enable docker experimental features ...

Set-Content -Value "`{`"experimental`":true`}" -Path C:\ProgramData\docker\config\daemon.json
Restart-Service docker

Verify that LCOW is enabled ...

docker version
docker info

Look for LCOW in command outputs ...

...
Storage Driver: windowsfilter (windows) lcow (linux)
...

Provide docker with LinuxKit packages ...

mkdir "C:\Program Files\Linux Containers"
cd "C:\Program Files\Linux Containers"
curl -OutFile release.zip https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip
Expand-Archive -DestinationPath . .\release.zip
rm release.zip

Test linux containers ...

docker run --interactive --tty ubuntu uname -a

Test linux container port exports

docker run --detach --publish 80:80 --name webserver nginx
curl http://127.0.0.1:80
docker container kill webserver

Test windows containers ...

docker run --platform=windows --interactive --isolation=process --tty mcr.microsoft.com/powershell:lts-nanoserver-1809 pwsh.exe -Command {hostname}

Test windows container port exports ...

docker run -d -p 8080:80 --isolation=hyperv --name iisweb mcr.microsoft.com/windows/servercore/iis
curl http://127.0.0.1:8080
docker container kill iisweb

Docker compose

Enable docker compose ...

$url = "https://github.com/docker/compose/releases/download/1.26.1/docker-compose-Windows-x86_64.exe"
Invoke-WebRequest $url -UseBasicParsing -OutFile $Env:ProgramFiles\Docker\docker-compose.exe

Clone sample app repository ...

docker run -ti --rm -v ${HOME}:/root -v "$((Resolve-Path .\).Path):/git" alpine/git clone https://github.com/btower-labz/docker-compose-sample-app.git

Execute and test sample app ...

cd docker-compose-sample-app
docker-compose -f app.yml up -d
docker-compose -f app.yml ps
docker container ls
curl http://127.0.0.1:5000
docker-compose -f app.yml kill

References

DockerCon: Linux Containers on Windows - The Inside Story

LunuxKit LCOW Sources

https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers

https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/hyperv-container

https://success.docker.com/article/how-to-enable-linux-containers-on-windows-server-2019

https://docs.docker.com/compose/gettingstarted

https://stefanscherer.github.io/sneak-peek-at-lcow

https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=Windows-Server

Docker Version

PS C:\Users\FtWCdd3aAa> docker version
Client: Docker Engine - Enterprise
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        2ee0c57608
 Built:             11/13/2019 08:00:16
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Enterprise
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.12.12
  Git commit:       2ee0c57608
  Built:            11/13/2019 07:58:51
  OS/Arch:          windows/amd64
  Experimental:     true