In this tutorial, we will look at how you can configure your Windows server to run Docker containers. Docker has been a game changer in Applications containerization and the whole microservices design and deployment patterns. Docker makes it easy to build, ship and run images containing applications with their dependencies and avoid crazy dependency issues common with the use of Virtual Machines.
Docker engine is what powers docker containers. It was originally written for Linux but a lot of work has been done to enable Windows and macOS users to run Docker containers.
One pre-requisite is the installation of a Windows server. This can be on a Virtual Machine running on-premise, a Physical server deployment or a Cloud instance running in Azure. You can refer to our installation guide below.
Before you can use the Windows Containers to run multiple isolated applications your system, you’ll need to enable the containers feature and install Docker on Windows Server.
Step 1: Enable the containers feature
The first step is to enable the Windows Server containers feature. Open “Windows PowerShell” –> “Run as Administrator“

Run the following commands to install DockerMsftProvider:
Enable-WindowsOptionalFeature -Online -FeatureName Containers
Accept by pressing the y key in your keyboard. You must restart compute, or do it manually:
Restart-Computer -Force
Step 2: Install Docker Engine
Once the Containers feature is enabled on Windows Server, install the latest Docker Engine and Client by running the command below in your PowerShell session.
Install Docker:
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
When the installation is complete, reboot the computer.
Restart-Computer -Force
Installed Docker version can be checked with the commands below:
PS C:\Windows\system32> docker version
Client:
Version: 27.0.3
API version: 1.46
Go version: go1.21.11
Git commit: 7d4bcd8
Built: Sat Jun 29 00:03:32 2024
OS/Arch: windows/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 27.0.3
API version: 1.46 (minimum version 1.24)
Go version: go1.21.11
Git commit: 662f78c
Built: Sat Jun 29 00:02:13 2024
OS/Arch: windows/amd64
Experimental: false
To manually start the service run:
Start-Service Docker
To stop Docker service execute;
Stop-Service Docker
Step 3: Run Docker Container
Start Docker Daemon before you start running and managing Docker Containers.
Start-Service Docker
Check docker service status.
PS C:\Windows\system32> Get-Service docker
Status Name DisplayName
------ ---- -----------
Running docker Docker Engine
Microsoft repository contains several base images, see Container base images for more details. Let’s see how you can download and install the base image:
Let’s download Windows Server Core image:
# 2022
docker pull mcr.microsoft.com/windows/servercore:ltsc2022
# 2019
docker pull mcr.microsoft.com/windows/servercore:ltsc2019
We can create a new container from the pulled image:
docker run -it mcr.microsoft.com/windows/servercore:ltsc2019
Step 4: Running Linux Containers
Enable Nested Virtualization if you’re running Docker Containers using Linux Virtual Machine running on Hyper-V.
Get-VM WinContainerHost | Set-VMProcessor -ExposeVirtualizationExtensions $true
Enable LinuxKit system for running Linux containers
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
Restart Docker Service after the change.
Restart-Service docker
Enable Experimental Features in Docker daemon.conf
$configfile = @”
{
“experimental”: true
}
“@
$configfile|Out-File -FilePath C:\ProgramData\docker\config\daemon.json -Encoding ascii -Force
Since Linux Containers need a Linux kernel, we need to deploy LCOW for it to run :
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\."
Pull a test docker image.
> docker run -it --rm ubuntu /bin/bash
root@1440a7fef7e0:/# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
root@1440a7fef7e0:/# exit
exit
To Switch back to running Windows containers, run:
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "$null", "Machine")
Enjoy running Linux and Windows containers on Windows Server 2022 or 2019. Drop us a comment in case of any issues.
Books For Learning Kubernetes Administration;
Also check: