Update on 1 Jul, 2020:
The development of lcow has been stopped, which means it would stay as experimental
forever. https://github.com/linuxkit/lcow
Docker Desktop has changed its way to leverage WSL2 for running Linux containers on Windows 10. The plan for Docker EE is unclear as Docker Inc. has sold it to Mirantis. https://github.com/docker/for-win/issues/6470#issuecomment-633883063
So if you plan to run both Linux and Windows containers in production, you may want to look for other options, such as Kubernetes.
Original post:
I never thought running Linux containers on Windows Server is a big deal. A reason that I run Docker for Windows on my Windows 10 laptop is to run some Linux based containers. I thought I just need to install Docker for Windows on a Windows Server 2016 server with Container feature enabled, then I should be able to run both Linux and Windows containers. I didn’t know it is not the case until when I tried it yesterday.
It turns out the Linux Containers on Windows (lcow) Server is a preview feature of both Windows Server, version 1709 and Docker EE. It won’t work on Windows Server 2016 of which the version is older than 1709. As a side learning of this topic, I also got some ideas about the Windows Server semi-annual channel. An interesting change.
So here is a summary of how to enable lcow on Windows Server, version 1709.
- First of all, you need to get a Windows Server, version 1709 up and running. You can get the installation media of Windows Server, version 1709 from here. As I use Azure, I provision a server based on the Windows Server, version 1709 with Container image. Version 1709 was only offered as a Server Core installation. It doesn’t have the desktop environment.
- Once you have the server up and running, you will have to enable the Hyper-V and Containers feature on it, and install the Docker EE preview. It can be installed with the following PowerShell script.
As I use the Azure image, the Container feature and Docker EE has been enabled on it, and docker daemon has been configured as a Windows service. I don’t have to run the above script. - Now you can follow the instruction here to configure the lcow. Specifically, I use the following script to configure it. I also update the configuration file in
C:\ProgramData\Docker\config\daemon.json
to enable the experimental feature of LinuxKit when docker service is started. - Once you finish all the above configuration, you have enabled the lcow on Windows Server 1709. To test it, simply run
docker run --platform linux --rm -ti busybox sh
That is it. If you want, you can also try to run Ubuntu containers by following the instructions here.