Docker Desktop users are unable to execute the WSL command. Some of the victims have just installed Docker Desktop, whereas some of them encountered this issue after updating the application. Following is the exact error message users see.
Docker Desktop – Unexpected WSL error
An unexpected error was encountered while executing a WSL command. Common
causes include access rights issues, which occur after waking the computer or not
being connected to your domain/active directory.Please try shutting WSL down (wsl — shutdown) and/or rebooting your computer. If
not sufficient, WSL may need to be reinstalled fully. As a last resort, try to
uninstall/reinstall Docker Desktop. If the issue persists please collect diagnostics and
submit an issue
( …: //docs.docker.com/desktop/troubleshoot/overview/#diagnose-from-the-terminal).
Fix Docker Desktop – Unexpected WSL error in Windows 11
If you get an Unexpected WSL error in Docker Desktop, first of all, do as suggested in the error message, that is, to shut down WSL using wsl –shutdown. If that doesn’t work, follow the solutions mentioned below.
- Install or update WSL
- Use Legacy Console
- Make sure Hyper-V, Virtual Machine Platform, and Windows Hypervisor Platform are enabled
- Reset Winsock
- Repair or reset the Windows Subsystem Linux
- Uninstall and reinstall WSL and/or Docker Desktop
Let us talk about them in detail.
1] Install or update WSL
To run the WSL command, you need to install WSL voluntarily. Most of the users are aware of this situation and have installed WSL, but maybe yours got uninstalled for some reason. There is no harm in installing it again and we will try to do the same. To do the same, open Command Prompt as an administrator and then run the command mentioned below.
wsl --install
Let the command run and install WSL for you. Once WSL is installed, check if the issue is resolved. In case WSL is already installed, you need to run the following command to update WSL.
wsl --update
After updating, check if the issue is resolved.
2] Use Legacy Console
Legacy Console mode is a compatibility tool meant to help users of older command-line tools. If you are unable to access WSL from your current Command Prompt console, switch to the Legacy Console. To do the same, follow the steps mentioned below.
- Open Command Prompt.
- Right-click on the header and select Properties.
- Tick Use legacy console (requires relaunch, affects all consoles) and click Ok.
This will do the job for you.
3] Make sure Hyper-V, Virtual Machine Platform, and Windows Hypervisor Platform are enabled
You need to ensure that Hyper-v, Virtual Machine Platform, and Windows Hypervisor Platform features are enabled. These are some of the features responsible for running WSL or any virtual environment. To do the same, follow the steps mentioned below.
- Open Control Panel.
- Go to Programs > Programs and Features.
- Now, click on Turn Windows features on or off.
- Make sure that Hyper-v, Virtual Machine Platform, and Windows Hypervisor Platform features are enabled.
Hopefully, this will do the job for you.
4] Reset Winsock
Winsock is a Windows Socket API that communicates between network software and services. If there is some glitch in Winsock that’s causing the issue, you need to reset it to resolve the issue. To do the same, open Command Prompt as an administrator and run the command given below.
netsh winsock reset
Now, reboot your computer and check if the issue is resolved.
5] Repair or reset the Windows Subsystem Linux
You may also face this issue if the installation of WSL is corrupted or misconfigured. We will first repair WSL and if that is to no avail, we will reset it. To do the same, follow the steps mentioned below.
- Open Settings.
- Go to Apps > Installed apps or Apps & features.
- Search for “Windows Subsystem for Linux”.
- Windows 11: Click on the three dots and select Advanced Options.
- Windows 10: Select the app and click on Advanced Options.
- Now, click on Repair.
If the issue persists, click on Reset. This will do the job for you.
6] Uninstall and reinstall WSL and/or Docker Desktop
If nothing worked, your last resort is to uninstall WSL and install a fresh copy. If the issue is caused due to corrupted installation media, reinstalling will do the job for you. In case the issue persists, do the same to Docker Desktop.
That’s it!
Read: Fix Server execution failed error in WSL.
How do I fix unexpected WSL error on Docker Desktop?
If you get WSL error in Docker Desktop, first of all, shut it down and then restart it. In case that doesn’t work, start executing from the first solutions and then move your way down.
Read: An error occurred mounting one of your file systems WSL error
Is WSL required for Docker Desktop?
Yes, you need WSL to run Docker Desktop on a Windows computer. It is recommended to install WSL 2 as it is the latest version and grant improved file system sharing capabilities.
Also Read: WSL2 not working? Fix Windows Subsystem for Linux Errors.