Docker Desktop - An unexpected error was encountered while executing a WSL command
Asked Answered
D

23

23

enter image description here

I'm getting the below error after installing a new version of Docker Desktop.

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 (https://docs.docker.com/desktop/troubleshoot/overview/#diagnose-from-the-terminal).

I am installing Docker Desktop in Azure Virtual Machine.

Any lead would be helpful. Thanks in advance.

Downthrow answered 3/5, 2023 at 6:20 Comment(2)
Are you using Azure VM Gen2? I had problems with running Docker there. After switch to Gen1 it was smooth.Endoplasm
If you trying to install Docker on windows, First of all try enabling virtualization in BIOS mode and then go for other solutions if it still doesn't work. For HP users Here is how- youtu.be/kmV-u85NY5A?si=PLnL_KWQ0dHCP6TC you might need to find a video relevant to your pc model.Repugnance
L
15

I got the same error and solved it by installing a Ubuntu Distribution. You need to install Ubuntu Distribution and set it as default Distribution of Windows Subsystem.

ScreenShot of how it looks after Ubuntu Distribution installed

Letishaletitia answered 7/6, 2023 at 13:29 Comment(2)
To install Ubuntu as the default distro, use wsl --installColum
This was my problem too. I'm guessing that there's an expected folder structure that doesn't exist without an instance--if you're strapped for disk space, pick the vanilla debian distro which is only ~100MB.Pandora
M
6

Here are some steps that worked for me.(Execute commands on Powershell)

I don't know if following steps solve your problem but at least it would give insight to you about problem.

Check installed distros and try to install it again.

wsl --status 

wsl -l #list wsl 

wsl –install or wsl.exe --install -d ubuntu

If you encounter with error when you are installing

Downgrade wsl version to 1 install distro and then upgrade to version 2.

wsl --set-default-version 1
wsl –install or wsl.exe --install -d ubuntu
wsl --set-default-version 2
wsl.exe --set-version ubuntu 2

Make sure that hypervisorlaunchtype auto by launching following command.

bcdedit /set hypervisorlaunchtype auto

Also make sure that all necessary(I know hyper v is not must for wsl2,nevertheless I enabled it.)

dism.exe /online /enable-feature /featurename:Microsoft-Hyper-V-All /featurename:VirtualMachinePlatform /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Market answered 11/7, 2023 at 13:15 Comment(0)
P
4

I got the same error installing this on a VMware VM guest. What I needed to do to make it work is activate the option 'Enable hardware assisted virtualization to the guest OS'. This makes sense since Docker is running a nested VM for the container engine. I'm not sure if a similar option is available in Azure, but that is where you'll want to look.

Pronty answered 9/5, 2023 at 23:55 Comment(1)
For virtualbox, this requires enabling nested virtualization from the command line (option is disabled in the UI for some reason) with vboxmanage modifyvm "windows-guest" --nested-hw-virt on.Barracks
I
3

In my case, I had disabled the Hyper-V hypervisor on a Windows system.

Solution

  1. bcdedit /set hypervisorlaunchtype auto
  2. shutdown /r /t 0 (Reboot your computer to apply the changes)
Improvident answered 12/12, 2023 at 9:48 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Mammilla
G
2

I encountered this after I wiped my system and reinstalled Windows 11. I tried a lot of the suggestions that I found here on SO and other sites. Docker kept wanting to update wsl as part of the installation because Docker Desktop needed a newer version of WSL. If I allowed the update, or ran wsl --update myself, my WSL would become gimped with an error msg displayed any time I tried to do anything WSL related, like wsl --update or wsl --status . Since docker was complaining about needing a newer version and wsl --update would break everything, I decided to try the following, which worked seamlessly =>

  1. Uninstall WSL and Docker Desktop
  2. Reboot (not sure this was necessary, but I'm superstitious)
  3. Go to WSL's releases on GH => https://github.com/microsoft/WSL/releases
  4. Download the latest release and install WSL. I downloaded the pre-release...
  5. Reinstall Docker Desktop

My understanding is that wsl --update --web-download should grab the latest version, but that did not work for me.

I am not sure that installing the pre-release was the key since as mentioned I did try the --web-download option.. so if you are stuck, you may want to try the a pre-release.

Guajardo answered 29/12, 2023 at 16:14 Comment(2)
wsl --update with PowerShell (Admin) resolved my issue! Thanks!!Temekatemerity
After being stuck on the failed loading and the "problem with wsl" message, I finally got it working with your answer. It seems step 3 was the "real cause" of the success, as it was the only new step I hadn't tried until then.Aphasic
T
1

you should check if the Linux kernel is available in the wsl with wsl --status then you can use wsl --update for updating the package, then check the docker desktop. if the issue still existed, you could use wsl --set-default ubuntu to set the default distribution.

Thursby answered 23/12, 2023 at 7:51 Comment(0)
R
0

take vm off and then enable nested vitualization and then it worked for me. https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization

Rugged answered 24/7, 2023 at 9:54 Comment(0)
M
0

things that work for me. Also solving my docker desktop issue related with WSL at the same time. Seems that current WSL from window store having issue with distribution.

  1. in Add or remove programs: uninstall first "Windows Subsystem for Linux Update" and then "Windows Subsystem for Linux"
  2. try to start your distribution again and it will point you to: https://aka.ms/wsl2kernel
  3. from there download the wsl_update_x64.msi file and run it, install the WSL kernel
  4. start your distribution again

https://github.com/microsoft/WSL/issues/9331#issuecomment-1665325130

Midships answered 4/8, 2023 at 9:47 Comment(0)
A
0

Facing the same issue, I managed to resolved it by doing a netsh winsock reset

Follow the steps outlined here, which consist in running command prompt/powershell with admin permissions and typing netsh winsock reset

Air answered 10/8, 2023 at 0:38 Comment(0)
S
0

I also experienced the same problem. But when I turned off the valet service, everything went back to normal.

NB: I used laravel valet for windows before. Make sure you stop the valet service before installing docker on windows.

valet stop

Sheen answered 11/9, 2023 at 11:34 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Mammilla
R
0

if you are using windows try with running docker with admin permission, it worked for me.

Redundant answered 13/10, 2023 at 14:0 Comment(0)
C
0

I have had a similar issue many times when turning on OS and then trying to switch on the docker desktop. The only solution that works for me is to turn off and then turn on the computer.

It's super annoying, however it works for me everytime

Cladoceran answered 18/10, 2023 at 7:49 Comment(0)
D
0

I solved the problem in three steps:

  1. Uninstall Docker Desktop from your computer.
  2. Run Docker Desktop setup as Administrator
  3. Open the Installed Docker Desktop as Administrator
Destined answered 8/11, 2023 at 7:44 Comment(0)
C
0

I was installing docker on windows 11 then had this issue. I think it is because I initially tried to install docker in a custom location from the command line (instead of double clicking the installer and have it do the default installation for me).

Here is what I initially did

  1. I installed docker by double clicking the installer. Let it do the default setup.
  2. I then felt like I want to install docker to a different place. So I uninstalled it, and reinstalled it to a different drive using command line arguments

The issue happened.

Then I uninstalled docker, an re-installed it by double clicking the installer. Everything works fine.

Culhert answered 22/11, 2023 at 10:50 Comment(0)
S
0

I had this same problem (the answer is the dumbest thing ever). turns out if your CMD is running on "legacy mode" docker will give this error. to disable CMD's legacy mode:

  • right click on CMD's title bar
  • properties
  • options
  • uncheck "use Legacy console"
  • select OK.
Sestos answered 7/12, 2023 at 2:7 Comment(0)
S
0

In my case I got this error on Windows 10 and NordVPN caused the problem. I realize this is probably not the OP's problem but could help others who come across this question.

Besides this docker error, I also would get the following error attempting to start a WSL command line: An operation was attempted on something that is not a socket.

When I turned off my Nord VPN (app still running, just disconnected from VPN) the docker error went away as did the WSL error.

Saxhorn answered 30/3, 2024 at 21:6 Comment(0)
T
0

open PowerShell in administrator mode Run command: 'wsl --update'

Temekatemerity answered 11/4, 2024 at 8:22 Comment(0)
M
0

I resolved the issue by opening the Command Prompt as an Administrator and running the command

netsh winsock reset

Then restarting the system!

Monophthong answered 18/4, 2024 at 12:11 Comment(0)
A
0

Solution:

Open powershell as administrator and type the command 'bcdedit /set hypervisorlaunchtype auto'.

Go to turn windows features on or off from start window button and c/o hyper-v , virtual machine platform,windows hypervisor platform ,windows subsystem for linux c/o ok and restart computer and do bios setting

How to go BIOS system configuration settings Restart computer and press f10 or esc button (for HP) and enable virtualization technology.

now you will not get error

Abridgment answered 21/5, 2024 at 17:52 Comment(0)
C
-1

The following steps worked for me:

  1. Rolled back to docker version 4.19
  2. In the BIOS, in the CPU settings, enabled SVM
  3. In windows fetchers, I turned on all the checkboxes for Hyper-V and Windows Subsystem for Linux
  4. perhaps some other commands that I entered an infinite number of times helped like bcdedit /set hypervisorlaunchtype auto

Some tips from this Q/A helped me too.

Caravan answered 19/10, 2023 at 14:42 Comment(3)
"In the BIOS, in the CPU settings, enabled SVM" - what does that mean? Usually, you don't use the BIOS on Azure VMsGlib
It it can be called differently on Intel processors "Virtualization Technology",If we do not enable this setting, we will not be able to enable low-level functions Hyper-VCaravan
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Mammilla
A
-1

I had exactly the same error on my Windows machine.

My solution: I enabled Virtualisation in my BIOS.


How to check whether this might fix your problem?

  1. Go to your task manager and open 'performance' and Click on CPU in the settings there need to be 'Virtualization': 'Enabled'

  2. If it's disabled the solution to your problem is enabling Virtualisation in your BIOS


How enable Virtualization in your BIOS?
This is depending on your specific SETUP and BIOS

But here is how it worked for me (this can be different for you)

  1. Enter BIOS by clicking del when starting your computer
  2. Click f7 in your BIOS and go to CPU settings
  3. Go to advanced CPU settings
  4. Enable Virtualization
  5. Click f10 and to save the changes and leave the BIOS
  6. After applying them check in your task manger again whether it says now 'Virtualization - enabled'
Avowal answered 15/11, 2023 at 18:34 Comment(1)
From the original post: "I am installing Docker Desktop in Azure Virtual Machine." - usually, you can't access any BIOS on AzureGlib
P
-1

Resolved the issue by just enabling the Hyper-V option in the BIOS.

You can verify whether it is enabled or not by following steps,

  1. Run-->msinfo32
  2. hyper-v - virtualization enabled in firmware "Yes or No" If Yes is enabled in BIOS, if NO not enabled in BIOS.
Peahen answered 30/11, 2023 at 13:47 Comment(1)
Please don't duplicate other answers. Enabling Hyper-V was recommended multiple times already, but I still think this is not an option on Azure VMsGlib
C
-2

This issue bothered me for several days as well.

Finally figured out that this is something related to the hardware setup. Entered into Bios & turned on the Virtualization Mode. After that, reopened docker application and it worked.

Can you double check whether yoru BIOS was reset or updated recently?

Christie answered 18/10, 2023 at 3:26 Comment(5)
Please don't duplicate existing answersGlib
Which existing answer would that be? @NicoHaase Can you provide a link? I only see similarities to a deleted answer and it was deleted several hours before this one was created. It is a strange coincidence, but if you see something malicious there, then it must be very much so....Ethicize
There are two answers about virtualization mode (https://mcmap.net/q/564460/-docker-desktop-an-unexpected-error-was-encountered-while-executing-a-wsl-command and https://mcmap.net/q/564460/-docker-desktop-an-unexpected-error-was-encountered-while-executing-a-wsl-command), and (as you refered to the deleted answer) entering the BIOS on an Azure system (which the OP Is using) is still not possibleGlib
None of the above anwsers mentioned get into BIOS and check what's going on there.Christie
Yes, because that's not possible: Azure Virtual Machines don't have a BIOS that you could accessGlib

© 2022 - 2025 — McMap. All rights reserved.