1

I have a very specific Docker/Windows question with very specific constraints. I hope I can find a conclusive answer ("no, it cannot be done", or "it can be done with these reproducible steps".)

I need to install the community edition of Docker, on Windows (not the licensed Docker Desktop, but the "raw" CLI).

This can be done in (the licensed) Docker Desktop using the DockerCli.exe program that comes with it. For example:

PS> .\DockerCli.exe -SwitchLinuxEngine

The need is to switch from using Windows containers to using Linux containers (in order to have dockerd pull and run some custom/legacy images that are based on Alpine.) Without this, Docker on Windows will complain as follows:

2020-09-18T03:30:24.0943834Z image operating system "linux" cannot be used on this platform

With Docker Desktop, this was no problem (just use DockerCli.exe to get the daemon to switch container strategies.)

But now that Docker Desktop requires a license, this is not an option (or it is not a preferred option.)

Unfortunately, I can't find a way to switch container strategies with just plain-vanilla docker (installed either with a direct release or via something like Scoop.)

So, my very specific question is this:

Can this be done on Windows with plain, bare-bones docker binaries, without relying on Docker Desktop, WSL2, etc? Maybe by using PowerShell to tweak the system, or using some other non-licensed and open-source CLI to do this magic?

I'm looking for a yes/no answer (and if yes, hopefully with reproducible instructions.)

If it cannot be done, I'm ok with that as long as I can document this.

Please note the strict context/constraints in which I'm framing this question.

Thanks, and have a great weekend.

PS.

I'm not looking to debate if WSL2 is good or not, or why I am not considering it as an option. Nothing wrong with WSL2, but there are operational constrains that make WSL2 a less desirable for a very specific business case (and which I'm not going to discuss here.)

Thanks.

6
  • To run Linux images, you need Linux. What's wrong with WSL 2?
    – Daniel B
    Commented May 15, 2022 at 20:32
  • "To run Linux images, you need Linux. " Uh, no you don't. You can switch Docker Desktop on Windows to switch engines, and thus run Linux images (as I documented in my question.) Nothing wrong with WSL2. There are biz requirements that preclude its usage, which I am not going to cover, and are not the subject of my question. My question is very specific, with very specific parameters, in hopes that experienced people can give a well-documented yes/no answer. Commented May 16, 2022 at 10:52
  • 1
    Yes you do. Because the “engine” is a Docker daemon running inside a Linux VM. You need Linux.
    – Daniel B
    Commented May 16, 2022 at 12:35
  • So, perhaps to clarify: Are VMs (Hyper-V, VirtualBox, VMware, QEMU, ...) entirely precluded?
    – Daniel B
    Commented May 16, 2022 at 12:53
  • @DanielB - dude, there's documentation that shows how you use Docker Desktop on windows to explicitly run linux images. I mentioned the CLI flags to do the switch on Windows right on my question. Seriously. Commented May 16, 2022 at 23:29

1 Answer 1

1

No, this is not possible. Not without a virtual machine.

To understand why, it is first necessary to understand how containers on Linux work: By utilizing kernel functionality to isolate process trees from the host system in certain regards. Usually, a container has its own:

  • PID namespace (it cannot see “outside” processes)
  • Mount namespace (it cannot see the host filesystem)
  • Network namespace (it appears as a separate host and cannot access host’s localhost)
  • IPC (it cannot do inter-process communication with “outside” processes)

You can run Linux binaries on Windows nowadays thanks to WSL. However, WSL 1 does not use a Linux kernel and as such does not support Linux namespaces. WSL 1 cannot run Docker containers.

Docker Desktop makes use of VMs to run Linux containers “on Windows”. It supports two modes of operation: Hyper-V and WSL 2. Hyper-V is the original way Docker Desktop worked, but it is not available on Windows Home editions. WSL 2 is built on top of the Hyper-V platform under the hood. It is available on Home editions. Like the original Docker Desktop Hyper-V VM, it runs a real Linux kernel.

When you “switch to Linux” on Docker Desktop, you switch to a virtual machine running Linux.

You cannot run Linux containers on Windows. Linux containers only run on Linux.

You can replace Docker Desktop with fully open source software and achieve (with some extra work) the same CLI experience. However, a VM is absolutely totally required.

1
  • Thank you, this explains it well. Much appreciated. Commented May 18, 2022 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .