WSL2 on Windows Server running Linux containers

This topic has showed up on multiple instances, so I wanted to let everyone know that you CAN run Linux containers on Windows Server 2022 via WSL2. The blog post describing how to do that is available here: Using WSL 2 on Windows Server 2022 to run Linux containers - Microsoft Tech Community

NOTE: Linux containers on Windows (both Windows Server as well as Windows 10/11) are supported for development and testing purposes.

5 Likes

My goal is to use Windows Server 2022 with WSL2 to compile Linux images as part of my CI/CD (the company doesn’t want to maintain Linux servers).

I assume it doesn’t work the same way as Docker Desktop does?
I can’t install Docker EE on the Windows Server and switch to use Linux images instead of Windows, and expect Docker EE to use WSL2 for it? I would have to explicitly get into Linux WSL (Ubuntu for example), install Linux Docker in it, and use that manually. Meaning, in my CI (Team City) I would have to manually execute commands to gain access to WSL2 docker, and execute manual commands there, as oppose to using the CI’s “Docker” build steps?

That is correct. WSL 2 is essentially a utility VM (to which you don’t have access, as WSL manages it for you) running Linux. Your description of how this would work is correct.

1 Like

Were you ever able to get this running?

I’ve made it as far as installing WSL2 and Docker/Linux, but I’m unsure of how to get a build pipeline (Azure DevOps Server in my case) to use WSL instead of EE.

I’m grateful for any tips you can provide.

I’m not sure this will work and please note that WSL2 on Windows Server is not supposed to be used on prod environments. If you have a need to run something Linux related on Azure DevOps, please use a Linux node.