Docker Desktop Installer.exe --backend=wsl-2 Is Not Working

I am trying to automate the installation of Docker Desktop and some Linux containers on Windows 11 Enterprise but am unable to default Docker to use WSL 2.

According to the Docker Desktop Installer documentation the --backend=wsl-2 parameter should setup Docker to run using WSL2. But when I launch “Docker Desktop.exe” for the first time it shows the error: “Required Windows features(s) not enabled: Hyper-V. Switch to WSL 2 base engine?” This stops automation and requires manual entry before installing the Linux containers.

A log file entry in c:\program data\Docker Desktop\install-log-admin.1.txt appears to know that WSL 2 is desired as it has this entry:

Selected backend mode: wsl-2

The Powershell script I am using to run the installer is the following:

Start-Process -Wait -NoNewWindow -FilePath "Docker Desktop Installer.exe" -ArgumentList "install --backend=wsl-2 --quiet --accept-license " -ErrorAction Stop;

But if I launch the installer manually/interactively and keep the default options then Docker Desktop is setup to use WSL 2 and doesn’t display this error.

Is there a workaround?

Note: Docker Desktop Version: 4.8.2

Things I’ve tried that have failed:

  • Using command-line instead of PowerShell

It can be a bug too. For example the error message is shown before it switches to wsl-2 backend. If it is a bug, you can report here:

but I don’t use Powershell often, so it is possible that the problem is in the Powershell (and command line) command, but I can’t tell.

Generaly your command doesn’t seem to be the problem. When I prefix the FilePath with .\ it works at least with Powershell 7.2.3:

 Start-Process -Wait -NoNewWindow -FilePath ".\Docker Desktop Installer.exe" -ArgumentList "install --backend=wsl-2 --quiet --accept-license " -ErrorAction Stop;

Note: after the installation is finished, the Powershell prompt does not return.

update: after a re-login, Docker Desktop opens, but displays “Docker Desktop stopped…”

update2: the two expected wsl-2 distros have not been created.

So indeed the resulting installation seem to be broken,