Run Docker Linux Containers on Windows Server 2019 (LCOW) - Step by Step Guide
In this article, I will show you how you can Install docker engine from DockerMSFTProvider and run both windows and Linux containers on this.
Prerequisites:
- Windows Server 2019 Installed on a VM or a host machine
- Virtualization Enabled
Steps:
- Enable Hyper-V and Containers Feature
- Install Docker EE
- Enable LCOW (Linux Containers on Windows)
- Run a Linux Container
- Install Docker-Compose (Optional)
1. Enable Hyper-V and Containers Feature
To enable windows Hyper-V and Containers feature, open PowerShell in administrator mode on your windows server 2019 and run this command:
Install-WindowsFeature -Name Hyper-V,Containers -IncludeAllSubFeature -IncludeManagementTools
You will need to restart your computer after installing these features
1. Install Docker EE
To install docker EE you will need to install the package provider and docker package
To install Package Provider run below command in PowerShell (Administrator Mode):
Install-Module DockerMSFTProvider
Now import the module and package provider
Import-Module-Name DockerMSFTProvider -Force
Import-Packageprovider -Name DockerMSFTProvider -Force
To check the latest version of docker on Package Provider, run this command:
Find-Package docker
Now you just need to install docker
Install-Package -Name Docker -Source DockerDefault
After installation, restart your computer and then type docker version in powershell to check the installed version of docker, if this works fine then installation is successful.
Now you can run any windows container on this. To run linux containers you will need to enable LCOW on your windows. See next steps to enable LCOW.
3. Enable LCOW (Linux Containers on Windows)
To run linux containers on windows we will need to make some changes in docker default configurations.
First we will set an environment variable to enable linux conatiners support.
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
Next we will create a docker daemon configuration file
$configfile = @"
{
"experimental": true
}
"@
$configfile | Out-File -FilePath C:\ProgramData\docker\config\daemon.json -Encoding ascii -Force
Finally we need to install linux kernel to run linux conatiners. Replace v4.14.35-v0.3.9 with latest version
Invoke-WebRequest -Uri "https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip" -UseBasicParsing -OutFile release.zip
Expand-Archive release.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\."
Now restart your machine to apply changes
4. Run a Linux Conatiner
Now to test if everything is working fine, we will run a linux test container. To run linux containers we need to specify the platform
docker run --rm -it --platform=linux ubuntu bash
If you are used to using docker-compose then you can install this as this is available for windows server as well. Replace "v2.8.0" to latest version.
You can get the latest release from this link:
https://github.com/docker/compose/releases
$dockerComposeVersion = "v2.8.0"
Invoke-WebRequest "https://github.com/docker/compose/releases/download/$dockerComposeVersion/docker-compose-Windows-x86_64.exe" -UseBasicParsing -OutFile $Env:ProgramFiles\docker\docker-compose.exe
Comments
Post a Comment