A few days ago, Docker and Microsoft announced the upcoming release of a new feature that will allow running Linux Containers on Windows Container Host.
Update: This article is for Windows Server Insider, please visit the article below for Windows Server 2016 Version 1709:
This feature is the #1 requested option by customers and developers and it looks like it’s getting closer to mainstream release.
I should say that the requirement to get this working is not simple and I’ve listed them below:
- Latest Windows Server 2016 Insider build
- Hyper-V role Installed
- Docker Windows Server Insider installed
The article below will help you configure all the above options.
Once all prerequisites are Installed and configured it works 100%.
How Does It Work?
At this stage, Linux Containers work by running a 2nd instance of Docker Containers on the Windows host that utilizing Hyper-V Containers.
Every time we need to create or access the Linux Container we need to do it from the 2nd instance while the Instance is running on a second window (you will see shortly)
Installing Docker and LinuxJit
Before you start this step, make sure Hyper-V and docker for Windows Server Insider are installed on the server.
To install Docker for Linux and LinuxKit run the cmdlet below.
$progressPreference = 'silentlyContinue'
mkdir "$Env:ProgramFiles\Linux Containers"
Invoke-WebRequest -UseBasicParsing -OutFile linuxkit.zip https://github.com/friism/linuxkit/releases/download/preview-1/linuxkit.zip
Expand-Archive linuxkit.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\."
Next, I’ll Install the daemon for the Linux support.
Invoke-WebRequest -UseBasicParsing -OutFile dockerd.exe https://master.dockerproject.org/windows/x86_64/dockerd.exe
In this very important part, I’ll run these two cmdlets and leave them running in the background.
Remember, this window needs to run all the time on a separate Windows.
.\dockerd.exe -D -H "npipe:////./pipe//docker_lcow" --data-root c:\lcow
Below you will see the two windows.
Next, I’ll download the Linux container image that is support for Linuxkit and Windows Containers.
Remember: You have to use the docker -H “npipe:////./pipe//docker_lcow” cmdlet before any command you want to run on the Docker for Linux
docker -H "npipe:////./pipe//docker_lcow" pull busybox
Once download, I’ll check that the image is there
docker -H "npipe:////./pipe//docker_lcow" images
And the million dollar moment, I’ll run a Linux Container on Windows Container Host
docker -H "npipe:////./pipe//docker_lcow" run -ti busybox
Below I run top inside my Linux Container
Running Linux Containers on Windows Server is a major shift and will change many things.
At this stage, there are a lot of requirements to get this done but it’s possible.