44

I have installed the Docker and then I have started the Docker. Docker says that "Docker is starting." Then,Docker says "Docker Failed to Start". Please, Could you help me?

Docker Error Detail:

System.InvalidOperationException:
Failed to deploy distro docker-desktop to C:\Users\---\AppData\Local\Docker\wsl\distro: exit code: -1
 stdout: The operation could not be started because a required feature is not installed.

 stderr: 
   at Docker.ApiServices.WSL2.WslShortLivedCommandResult.LogAndThrowIfUnexpectedExitCode(String prefix, ILogger log, Int32 expectedExitCode) in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\WSL2\WslCommand.cs:line 146
   at Docker.Engines.WSL2.WSL2Provisioning.<DeployDistroAsync>d__17.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\WSL2Provisioning.cs:line 169
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.Engines.WSL2.WSL2Provisioning.<ProvisionAsync>d__8.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\WSL2Provisioning.cs:line 78
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.Engines.WSL2.LinuxWSL2Engine.<DoStartAsync>d__25.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\LinuxWSL2Engine.cs:line 99
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.ApiServices.StateMachines.TaskExtensions.<WrapAsyncInCancellationException>d__0.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\TaskExtensions.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 92
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Docker.Engines.Engines.<WaitCurrentTransitionsAsync>d__30.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\Engines.cs:line 358
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.Engines.Engines.<RestartAsync>d__26.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\Engines.cs:line 250
Yavuz Yoldaş
  • 841
  • 1
  • 9
  • 19

14 Answers14

70

In my scenario, I needed to install WSL 2 and my computer didn't have it. Installing it made docker run successfully. Try the below steps if you are installing docker for the first time.

First, we need to activate WSL from Windows.

Control Panel -> Programs -> Turn Windows features Turn On or Off

You need to check

  • Windows Subsystem For Linux
  • Windows Hypervisor Platform
  • Virtual Machine Platform

Then Click ok

Turn Windows features Turn On or Off

After that, you need to Enable WSL 1 and update it to WSL 2 (https://learn.microsoft.com/en-us/windows/wsl/install-win10#manual-installation-steps)

To Install WSL 1 which comes built-in, open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

After that download the WSL 2 update from Microsoft. Use below this: WSL2 Linux kernel update package for x64 machines

After installing the above package, you need to set WSL 2 as the default version.

Open PowerShell as Administrator and run:

wsl --set-default-version 2

Now restart your computer. Now your docker should work.

Please note that to update to WSL 2, you must be running Windows 10.

  • For x64 systems: Version 1903 or higher, with Build 18362 or higher.
  • For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
Shane Bishop
  • 3,905
  • 4
  • 17
  • 47
Menuka Ishan
  • 5,164
  • 3
  • 50
  • 66
  • 1
    I got `WSL 2 requires an update to its kernel component.` and had to run `wsl --update` (as Administrator) and then `wsl --set-version Ubuntu-20.04 2` to upgrade my existing wsl (took about 8 min) – Vl4dimyr Sep 18 '21 at 19:35
30

My Solution:

I have checked the Prerequisites for Docker. I have applied the second step in prerequisites. (Windows Subsystem for Linux Installation with Manual Installation Steps) It has fixed the error for me.


If you get an error like this (during this installation process):

WslRegisterDistribution failed with error: 0x80370114 Error: 0x80370114 The operation could not be started because a required feature is not installed. (I encountered this error.) Please, apply this.

 These steps are quoted from the "this" named hyperlink above. 
1. Open "Windows Security"
2. Open "App & Browser control"
3. Click "Exploit protection settings" at the bottom
4. Switch to "Program settings" tab
5. Locate "C:\WINDOWS\System32\vmcompute.exe" in the list and expand it
6. Click "Edit"
7. Scroll down to "Code flow guard (CFG)" and uncheck "Override system settings"
8. Start vmcompute from powershell "net start vmcompute"
9. Then go back and command wsl --set-default-version 2

I have fixed my problems like that. Good luck :)

Yavuz Yoldaş
  • 841
  • 1
  • 9
  • 19
  • 3
    While the link may provide a solution, it may become stale/broken/etc, so please, edit your post and add the solution worked for you (the link at the end) as a part of an answer. Here's the reason: [Your answer is in another castle: when is an answer not an answer?](https://meta.stackexchange.com/questions/225370/your-answer-is-in-another-castle-when-is-an-answer-not-an-answer) – astentx Jul 09 '21 at 23:56
  • 1
    Thanks, in my case, I had to install the WSL2 Linux kernel update package for x64 machines – Chris Gong Aug 18 '21 at 15:40
11

Docker failed to start WSL 2 update I just did this on powershell

wsl --install -d Ubuntu
wsl --update
wsl --shutdown
ZootHii
  • 800
  • 1
  • 8
  • 16
3

The problem is in WSL as it becomes unresponsive and returns a service error. Follow the below steps

1. Uncheck the Windows Subsystem for Linux in Windows Features
2. Restart
3. Turn the feature back on
4. Re-apply the WSL2 update
5. Restart
Ashok
  • 3,190
  • 15
  • 31
1

I was facing the same problem in my windows cooperate desktop. Unfortunately most of the windows settings changes are not available for users and controlled by IT team. What I did to make docker running is

  • Open Docker Desktop
  • Go to Settings
  • Turn off "Use the WSL 2 based engine" which switch to legacy Hyper-V

I know this is not ideal but atleast got docker working.

jprism
  • 3,239
  • 3
  • 40
  • 56
0

The combination of the above answer and installation of new destro worked for me

  1. Uninstall existing installation
  2. Install With Admin privilege
  3. Restart
  4. Follow the accepted answer here https://answers.microsoft.com/en-us/insider/forum/all/wsl-2-installing-linux-failed-error-code/bae391d1-4215-4d93-b0c4-3d96404a7c74
  5. Install a linux destro follow this https://learn.microsoft.com/en-us/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package
  6. Launch Linux desktop as admin
Pranoy Sarkar
  • 1,965
  • 14
  • 31
0

Fyi -- jprism's answer worked for me.

My issues were...

  • Docker install worked but would not start successfully, I got "WSL not installed" message.
  • Tried the WSL installation instructions from https://learn.microsoft.com/en-us/windows/wsl/install
  • Default WSL installation was not found from PS session. Would not run from the command line without specifying the distro. Worked when I explicitly specified the default distro with the -d argument
  • Enabled WSL Subsystem as per https://www.windowscentral.com/install-windows-subsystem-linux-windows-10
  • Enabled all Hyper-V options in Control Panel > Programs and features > Turn Windows features on or off in addition WSL Subsystem
  • Finally as per jprism modified Docker settings to use Hyper-V
bad_coder
  • 11,289
  • 20
  • 44
  • 72
LaaRay
  • 1
  • Please don't add "thank you" as an answer. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation), you will be able to [vote up questions and answers](https://stackoverflow.com/help/privileges/vote-up) that you found helpful. - [From Review](/review/late-answers/29912791) – All Downhill From Here Sep 24 '21 at 17:53
0

this can help you

& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

run this in powershell.

Sougata Das
  • 169
  • 1
  • 3
  • 1
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Abhishek Dutt Nov 14 '21 at 03:53
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Abhishek Dutt Nov 14 '21 at 03:53
0

WSL2 cannot running.Reset winsock can fix it. Use following steps.

PS C:\WINDOWS\system32> wsl.exe --shutdown
PS C:\WINDOWS\system32> wsl.exe
The attempted operation is not supported for the type of object referenced.
PS C:\WINDOWS\system32> netsh winsock reset
Successfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

After reboot ur system please run this command:

PS C:\WINDOWS\system32> wsl.exe

This will solve this error. I got it resolved at my machine.

MANITORATION
  • 557
  • 2
  • 5
  • 19
0

Much much easier solution:

On Windows 11 with Docker Desktop v4.13.1 everything works fine with both Linux and Windows containers. Than after a couple of restarts I suddenly get the same error (Docker failed to start etc.)

Click on Troubleshoot in the header menu. Here you can Clean / Purge data, after that it works again.

enter image description here

WARNING: this solution will delete your Containers and Images. You can select what to delete after the Clean / Purge data selection:

enter image description here

Cerveser
  • 752
  • 8
  • 23
0
  1. Uninstall Docker Desktop
  2. Delete the following:

delete %appdata%\Docker*

delete %appdata%\Docker Desktop*

delete %LOCALAPPDATA%\Docker*

  1. Reinstall Docker Desktop

Source

diman82
  • 702
  • 8
  • 11
0

check if windows Update is running in services. If not, start it

  • Also mention how to do , how it would look ! Please check https://stackoverflow.com/help/how-to-answer – Harsh Apr 04 '23 at 04:47
0

Follow the installation instructions on home page of docker. Also make sure to enable WSL if your using window 10 or below. This step is not required if your on Windows 10 pro or above.

Link to enable WSL in windows.

Also below error also occurs if you do not start the docker desktop windows application and try to execute the command inside terminals.

The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/
-1

What fixed this for me was

  • Hit windows key, type "cmd", hit enter
  • Right click menu bar, select "Properties"
  • Uncheck "Use legacy console"
Matt Wright
  • 102
  • 1
  • 4