(using WSL ubuntu app) system has not been booted with system as init system (PID 1). Can't operate [duplicate] - docker

This question already has an answer here:
Enable Systemd in WSL 2
(1 answer)
Closed 2 months ago.
I'm a very first user of Ubuntu. I failed to install Ubuntu in wmware ,so I installed Ubuntu application in Microsoft app store and everything was quite all right.
But when I insert shutdown or halt command to power off my ubuntu I kept getting 'system has not been booted with system as init system (PID 1). Can't operate' error message.
I tried to using docker following with this link (https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/) but I failed after going to Number 2 process many times. I'm not sure my failure is because of installing docker toll box instead of normal one. (my computer is just windows 10. not a windows pro)
I think I have to try other thing. If you don't mind me asking, how can I slove this problem?
(and one more. If I just click 'X' button at the top of right side, is it different with shutting down Ubuntu using 'halt' or 'shutdown' command?
Thank you

I found this useful: https://linuxhandbook.com/system-has-not-been-booted-with-systemd/
In my case
# start docker using systemctl
sudo systemctl docker start
# returns:
#
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
The basic advice is:
# check if your system is using `systemd` or `sysvinit`
ps -p 1 -o comm=
If the command doesn't return systemd, and in my case, Ubuntu-20.04 on WSL, the command returned init, then use the command pattern
# start services using sysvinit
service docker start
This works for me.

Based on this: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
systemd is now available in WSL Version 0.67.6 or higher.
To enable:
Open a command prompt:
# CHOOSE option A or B:
# A. check your version and ensure it is 0.67.6 or higher
wsl.exe --version
# B. run WSL update if the version is low
wsl.exe --update
Open a WSL prompt:
sudo nano /etc/wsl.conf
Add this to wsl.conf and save the file:
[boot]
systemd=true
Go back to the command prompt:
# warning: this will kill any shells/processes you have running!
wsl.exe --shutdown

First of all, Ubuntu installed via MS Store is using WSL (Windows Subsystem for Linux) Technology. It simply means there is no virtualization, Windows and Linux kernels are living side by side (the Linux kernel is not fully implemented yet).
So if you are trying to "shut down your Ubuntu", you would turn off the whole computer just like the Windows does. But in this case, WSL doesn't apparently have rights to do that.
In other words, you can look at your Ubuntu bash window just like any other terminal, like e.g. CMD or PowerShell.
When you start a program in the WSL (Ubuntu), you can see it also in Windows Task Manager - that's just a proof, that there is no virtualization.
Regarding docker:
If I'm not mistaken Windows 10 Home doesn't provide Hyper-V virtualization. It means you'll have to use a different one e.g. by using VirtualBox. In order to make it work, I can recommend you to follow this tutorial and especially for VirtualBox please check this answer here
Hope it helps :)

Related

Any reason not to remove Docker as default WSL distro?

I have the latest version of Windows Subsystem for Linux (WSL) installed, but when I run wsl from the command line I get the following error:
An error occurred mounting one of your file systems. Please run ‘dmesg’ for more details.
I hunted down a few possible explanations and one is the possibility that Docker is set as my default wsl. Sure enough, when I run wsl -l -v, the response is:
NAME | STATE | VERSION
* docker-desktop-data | Stopped | 2
docker-desktop | Stopped | 2
To correct this, I am told to change the default from Docker to something else with the command wsl -s distroName where “distroName” should be changed to … something.
So I have two questions:
What should I type instead of “distroName”?
Will Docker Desktop still perform as intended if I do this?
If you're not using WSL for anything other than Docker Desktop, then it really doesn't matter.
But since you attempted to run wsl, it sounds like you may want to try it out. In that case, you should definitely install a WSL distribution that is meant for interactive use.
The docker-desktop and docker-desktop-data distributions aren't really intended to be accessed directly by the user, but one of them will get set as default if you don't have any other distribution installed. There's a proposal to have a way for Docker to set these as "hidden" so that WSL wouldn't automatically set either as default.
What should I type instead of “distroName”?
First, install a user distribution. Which one you choose is up to you, but I typically recommend Ubuntu for first-time installs. When installing WSL on recent Windows releases, it should be the default.
It's installable via the Microsoft Store -- Just find the one that says "Ubuntu" (with no version number). It will install the latest release.
Then, in PowerShell;
wsl --set-default Ubuntu
Will Docker Desktop still perform as intended if I do this?
Absolutely -- It's really an error/corner-case/oversight that docker-desktop-data ever gets set as default anyway, which is why it's nice that the WSL team is considering a method to prevent this.

Ubuntu Error "The command 'docker' could not be found in this WSL 2 distro."

I'm running WSL 2 on Ubuntu and having some issues getting docker up and running on my computer. I have Docker Desktop installed and running in the background, and I also have WSL integration enabled with Ubuntu.
When I try to run simple docker commands, such as docker --version, I receive this error:
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/
I have already visited the link and followed all the instructions it gives, enabling WSL integration with Ubuntu as shown here:
However the error I receive is still the same. Does anyone know how to fix this?
Note: I can run Docker commands (such as docker --version) in PowerShell and Command Prompt, but it is unrecognized in Ubuntu.
"Docker Desktop" should integrate into WSL without additional configuration. Especially, it should not be necessary to append folders to the PATH environment variable.
Of course it must be made sure that "Docker Desktop" as well as the certain WSL distribution are set up for WSL2: In "Docker Desktop" settings "General/Use the WSL2 based engine" must be checked and wsl -l -v should list version 2. If the latter is not true, it can be fixed by wsl --set-version <distribution> 2, where <distribution> is the name from the previous list. Note that "Ubuntu" and "Ubuntu-22.04" (for example) are different.
"Docker Desktop" normally integrates with the default distribution. It can be seen from the asterisk in wsl -l -v which one had been chosen. For me this once was set to "docker-desktop-data" (probably because "Docker Desktop" had been installed earlier than the distribution). The default distribution can be changed by wsl --set-default <distribution>. Furthermore, in "Resources/WSL integration" of "Docker Desktop" settings, the option "Enable integration with my default WSL distro" must be set.
If another distribution than the default one should use docker as well, it needs to be selected explicitely in the list of distributions of "Resources/WSL integration". Press "Refresh" if that other distribution had been installed recently while "Docker Desktop" was already running.
"Integration" means, as far as I can tell, that a link /usr/bin/docker, pointing to /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker, is created automatically. Since /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker seems to be available in all distributions regardless of the integration setting, the presence (or not) of /mnt/wsl/docker-desktop/cli-tools/usr/bin and its content might help to analyse the problem. There should be docker, docker-compose and others:
ls -l /usr/bin/docker
ls -l /mnt/wsl/docker-desktop/cli-tools/usr/bin
I was having this problem, so I went to this docker link (your link is broken) and worked through the suggestions.
This worked for me:
In PowerShell, type wsl -l -v and you should get something like this:
NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 2
Ubuntu-20.04 Running 2
docker-desktop-data Running 2
Go into the Docker Desktop Settings -> Resources -> WSL integration.
Select the WSL 2 distro you are using from the above list (e.g. Ubuntu 20.04 in my case) and Apply & Restart.
Now running the version command works as expected in my distribution, and I have all of the functionality required from within the WSL terminal.
:~$ docker -v
Docker version 20.10.16, build aa7e414
Try to put following line in your Ubuntu's ~/.bashrc
PATH+=":/mnt/c/Program Files/Docker/Docker/Resources/bin"
( It might be /c/Program Files/... depending on your mount point. You can check with the command df )
and start a new bash shell, then run docker.
I was able to fix this by taking the below steps but it required some work arounds because I was unable to click-install the necessary WSL2 Linux kernel update after downloading.
Then I had to complete this process.
Then I had go to the PowerShell command line and navigate to the location of the above WSL Update and run the following (in administrator mode-- and not in the Linux command line):
& '.\wsl_update_x64.msi'
That was the only way I could successfully install the update
Then at Powershell command line (in administrator mode-- and not the linux command line), I ran
wsl --set-version Ubuntu 2
per instructions here
Today I had this problem too. In WSL I got a message that I could update WSL from the microsoft store. So I updated WSL and after that moment docker wasn't on my PATH anymore.
It was a lazy saturday morning, so I decided to restart my PC. And magically the problem was "fixed".
Maybe it would be enough to restart WSL distro, at this moment I don't have the time to research whether that would be a good solution.

"Docker Desktop Starting..." forever on Windows

I have installed Docker Desktop version 4.4.4 and it is not running. It only displays "Docker Desktop Starting ..." but never starts running.
I have tried so many ways but didn't solve:
Allowing the following files in windows firewall C:\program files\docker\docker\resources\vpnkit.exe, C:\program files\docker\docker\com.docker.service C:\program files\docker\docker\resources\com.docker.proxy.exe
Removing 'Docker' and 'Docker Desktop' folders from AppData/Roaming and AppData/Local
Uninstalling and reinstalling Docker with different versions including 4.5.1
The main problem is WSL2 does not auto install the kernel when WSL2 installs, yet Docker Desktop expects it already installed. So, fully close & stop Docker as other answers have said, then run this cmd as admin:
wsl --update
Now open Docker Desktop & it should start up ok.
I've found out another symptom leading to the solution is also related to WSL.
On one side, Docker service won't start throwing this error:
error during connect: This error may indicate that the docker daemon
is not running.: Get
"http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version": open
//./pipe/docker_engine: The system cannot find the file specified.
And on the other, WSL is unresponsive. Attempting to run a WSL Distro or WSL command directly on CMD, won't return any output at all. It will just hang in there.
So the solution is common to WSL and Docker.
I've found in a question regarding the WSL issue, that the LxssManager Windows service is staled (it may show under services.msc as Stopping and all the buttons are greyed out, or I've even seen it Running apparently, but with the Docker and WSL issues above, so something is wrong with it still.)
First, we have to get LxssManager PID in order to kill it. Using an elevated shell, we can get it this way:
sc queryex LxssManager
Having the PID, we can kill the process but beware I wasn't able to kill it using kill or taskkill commands. I was getting the following error:
ERROR: The process with PID XXXXX could not be terminated.
Reason: Access is denied.
To effectively kill the process, do as following:
wmic process where ProcessID=XXXXX delete
Replace XXXXX with PID, of course.
Having done so, start the LxssManager service:
net start LxssManager
A word of warning:
I've noted in some cases this is not enough for unknown (to me) technical reasons even if LxssManager service is shown as Running.
Just repeat the above steps! Sometimes it works doing this once, sometimes doing it twice for some reason.
TL;DR
Kill LxssManager Windows service using wmic+PID.
Start LxssManager service.
Repeat twice or more if issues persist.
Docker and WSL issues are solved.
Here i am using Windows platform, I faced this issue.
And to resolve this issue follow the below steps.
Just delete the temporary files from the following.
C:\Windows\Temp
C:\Users{yourAccountName}\AppData\Local\Temp
C:\Windows\Prefetch
then
Uninstall Docker Desktop
Restart computer
before installing docker, make sure you have Ubuntu WSL(download from Microsoft store)
[optional] If you need Terminal Preview(multi-terminal) download from Microsoft Store. Great Terminal
Install Docker Desktop Again
Thanks
For me, it was a problem with WSL. When I tried:
wsl --install -d Ubuntu
in a command window, after a few minutes I got error 0x80370114
The fix was to do:
Exploit Protection > System Settings > Control Flow Guard
turn on
restart computer
Then reinstall/restart Docker Desktop, and it works!
Hope this helps someone else
I was facing same code for for Docker version 4.*. For me it was Visual Studio code,
Stopped WSL form Task manager
stopped Docker which was showing "Docker desktop is starting" form Task manage
stopped Visual Studio code form Task manager
Started Docker again
These steps placed my Docker in Running state in 30 seconds
Hope this helps someone!
Solved this issue with #Alvi answer
Docker forever in "Docker is starting.." at Windows task
I guess you are using wsl2 features. In that case, open PowerShell or command prompt and type: optionalfeatures.exe
scroll down and uncheck
Windows Subsystem for Linux
apply the changes and restart your computer.
After restart follow the previous steps again and check
Windows Subsystem for Linux
and restart again. Hopefully now your docker will run
My fresh install was experiencing the same symptoms. Also wsl --list showed "no installed distributions". I tried many reinstallations and restarts of Docker and WSL, but eventually found the steps:
In Task Manager, kill all processes related to Docker & Docker Desktop
Run Docker Desktop as administrator
Got it working on on Windows 11 Enterprise.
for me it worked in windows (docker desktop):
to uninstall the docker
reinstall as administrator
don't select the part with wsl
As wrote here, you need to do:
wsl --update
But after that it doesn't fix my issue until I did restart to my pc.
What worked for me was to log in into the Docker (upper right corner), but when I first clicked on login, it said "exec: "rundll32": executable file not found in %PATH%" - I search and found that I need to check environmental variable in PATH that I have "C:\WINDOWS\system32" there - (and in my case I really had it broken somehow - don't know why, but I missed backslash between Windows and system32). So I fixed to correct path, restarted PC. Then I was able to login. And immediately "Docker Desktop Starting..." was gone.
I use Docker with PyCharm. I ran into this problem when I launched PyCharm and Docker Desktop at about the same time.
On my machine Docker Desktop starts automatically when I boot. I can avoid the problem by waiting for Docker Desktop to finish starting. And then start PyCharm.
I was also having the same problem, just a few minutes ago.
Platform:
Windows 10 Pro - 22H2 - Build 19045.2486
Windows Updates newly installed: KB5022282, KB5020876, KB5012170
What i did was: Activating the Windows Hypervisor Platform
And it did solve the problem, atleast for now
In my case it helped me to enable the CPU SVM (Support Vector Machine) function in my BIOS settings.
Also, if you have this feature disabled, you will not be able to use Virtual Box either.
SVM in BIOS
got to services and stop Docker desktop service and start again
reopen Docker desktop it will work
wsl -v
if it show version then linx is install
search windows programer feature in your laptop
enable virtulization
wsl --set-default-version 2
restart laptop and then start docker and wait for 2 minutes your docker will start working
I am running windows 11, visual studio 2023 and had this issue.
First, open a command prompt and type
wsl.exe --list --online
Then enter following
wsl.exe --install Ubuntu-20.04
Then type in the prompt sudo apt update to update the distribution. Lastly, start up Docker desktop and log in (you can register at their site). That fixed Docker on my pc.

System.InvalidOperationException: Failed to deploy distro docker-desktop to <localpath>: exit code: -1

I am trying to run docker Desktop in my windows 10 Local. have installed it successfully but while running it I am getting the below error.
System.InvalidOperationException:
Failed to deploy distro docker-desktop to <localpath>: exit code: -1
stdout: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.
I think it is saying some windows services need to be enabled, but I don't know which service has to be enabled could someone please help me with this concern?
docker version
C:\Users\lenova>docker --version
Docker version 20.10.2, build 2291f61
Uninstall Docker.
Uncheck Containers, Hyper-V, Windows Subsystem for Linux in Windows features
Restart the system
Install Docker Desktop
Restart System
Start Docker Desktop
Right click on docker icon, run as administrator (if you have administrator rights on your computer). It solved the problem for me.
Try delete %USERPROFILE%/.wslconfig. If it helps then you can try to modify it so that it work. As for me I deleted the file, because on my workstation docker didn't want to work with it
Almost sure, that the accepted answer will work. However, it won't be an option, if you utilize WSL for other purposes as well. In that case, you may have several configurations/apps in WSL and just reinstalling or deleting your configuration will probably be a bad solution.
Furthermore: WSL is not the issue for this error! It is created by Docker engine configuration which will kill the WSL service (LxxsManager). This may happen because of
changed configuration (by you) or
because of a Docker update, maybe also
because of Windows updates
You can find a detailed discussion about this issue on Docker's GitHub Issues.
I personally experienced this problem after installing updates on Windows while running Docker v3.5.2. And again, reinstalling/killing WSL is not an option for me! So I tried to kill all services (Docker and WSL) and update Docker. Unfortunately that did not work in first place, since LxxsManager was in some weird state and I could not even kill it any more (even a kill command as admin with force switch did not do it's job!)... So here is my solution to fix that problem:
Remove Docker from autostart
Restart Windows (Yippiee: WSL works again! 🥰)
Install a new version of Docker (in my case v.4.2.0)
Restart Windows again (probably not necessary, but for me it was because Docker engine did not start before a Windows restart)
Start Docker (Yippiee: Docker works again! ☺️)
Note: Since I did not change Docker configuration, I installed an update. If you changed configuration options resulting in that crash, your solution may be different. Literally, instead of updating Docker (step 3) you would probably roll back your Docker configuration changes instead.
The quality of Docker for Windows is very bad. I catch these dangerous very often.
Check list:
(1) Use this tool https://www.nirsoft.net/utils/regscanner.html . Search docker, delete all.
(2) Remove WSL sub system, Hyper-V, then restart
(3). Create file foo.reg has content
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\\Windows\\System32\\wsl.exe"
"PermittedLspCategories"=dword:80000000
run.
(4) Uninstall Docker
(5) Run cmd type ... . Delete folder .docker
Delete Docker folder in Program Files
(6) delete
(7) Install latest version of Docker.
(8) Re-install feature WSL for Windows.
Install Ubuntu from Windows store
(9) Re-install Docker (as Administrator)
(10) Run Docker as Administrator .
In my case, I was getting a similar error. This was happening because Docker desktop didn't have permissions to access the path C:\Users\Adithya\AppData\Local\Docker\wsl\distro. This started happening after I switched to WSL2 backend.
The solution was to kill all docker process. Next, Run Docker Desktop as Administrator.
System.InvalidOperationException:
Failed to deploy distro docker-desktop to C:\Users\Adithya\AppData\Local\Docker\wsl\distro:
exit code: -1 stdout: The operation timed out because a response was not received from the virtual machine or container.
run as administrator , and you switch the container to windows by clicking the icon bar in the right corner taskbar and choose switch to windows container
https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-10-linux
If you don't need to run Linux and Windows containers side-by-side, an option is to turn off the WSL and use Hyper-v instead. This should work fine.
I had to exit Private Internet Access (PIA) VPN to get docker to work on my system. Not sure why.
I had the PgAdmin 4 app running, and when I closed it and tried starting Docker Desktop again it booted normally.
Not sure if there is a link, but an easy solution to try.
This worked for me: https://github.com/MicrosoftDocs/WSL/issues/547#issuecomment-873540236
Copy below snippet:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\\Windows\\System32\\wsl.exe"
"PermittedLspCategories"=dword:80000000
Save it as a file wsl.reg
Execute the file to update the registry
Launch Ubuntu again
Issue resolved
In my case, the issue was caused by Acrylic DNS server. Anything that holds port 53, would be a problem.
Interesting that it all worked fine for a few days after installation, maybe because I did not reboot the laptop all that time, only used the deep hibernation. So it was hard to guess what could break the docker setup, I was sure that it was because of the recently installed windows or docker updates.
Restarting wsl worked for me.
Run the following
wsl --shutdown, wait for it to shutdown
wsl, wait for it to start
Start Docker Desktop after this.
On Windows 10:
Open Services
Right click on LXSSMANAGER -> Restart
Close wsl using cmd with following command:
wsl --shutdown
Execute following start wsl again:
wsl
I solved by the following steps:
Uninstall Docker and WSL 2 kernel.
Uncheck Containers, Hyper-V, Windows Subsystem for Linux in Windows
features
Restart the system
Install Docker Desktop
Restart System
Start Docker Desktop
The problem is in WSL as it becomes unresponsive and returns a service error if you try the following command in PowerShell:
wsl -l -v
I believe the process can be simplified a bit more with:
Uncheck Windows Subsystem for Linux in Windows Features
Reboot
Turn the feature back on
Re-apply the WSL2 update
Reboot
No need to uninstall/reinstall Docker Desktop.
This got me back up and running with Windows 10 Home (which requires WSL2) and Docker Desktop 2.4.0

Docker forever in "Docker is starting.." at Windows task

I have installed a Docker stable version, and it took forever to start.
Until now I have not seen the notification showing Docker is running.
I can only see the Docker icon at the taskbar, showing Docker is starting.
I am running on Windows 10 Pro, Intel Core 2 Duo E8500, supporting virtualization.
Important Note: As #Nachtalb said, "I think it should be noted that
this removes all docker containers and data. (WLS: Unregisters the
distribution and deletes the root filesystem)."
Thanks to https://github.com/docker/for-win/issues/7050, you should just run these two lines of commands inside PowerShell:
First, exit the docker hub desktop, then run these commands in PowerShell:
wsl --unregister docker-desktop
wsl --unregister docker-desktop-data
How to Fix Docker for Windows "Docker Is Starting..." Error
I stumbled upon the solution which turned out to be super simple!
When Docker installs on a Windows device it doesn't bother to check if your Operating System is Windows, not Linux! So, it tries to start up looking for Linux containers that do not exist. Just set it to run under Windows containers!!
SOLUTION
In the lower right-hand corner of Windows, in your Notifications/System Tray section, right-click the docker "whale" icon.
In the context menu that pops up, choose "Switch to Windows containers..."
This should unfreeze "Dockers for Windows" instantly! If it does not, close "Dockers for Windows" and open it again.
:) peace
Personally, the most non-destructive method for myself has been to use:
wsl --terminate docker-desktop
wsl --terminate docker-desktop-data
Close Docker Desktop GUI (cancel/close any error messages)
Start Docker Desktop again.
Docker then indicates its starting the wsl services during its start process and my issues are resolved.
Other methods (like register/unregister) tend to be much more destructive and I lose configuration/data/volumes.
I guess you are using wsl2 features. In that case, open PowerShell or command prompt and type: optionalfeatures.exe
scroll down and uncheck
Windows Subsystem for Linux
apply the changes and restart your computer.
After restart follow the previous steps again and check
Windows Subsystem for Linux
and restart again. Hopefully now your docker will run
This is followed by docker/for-win issue 487 and mostly: issue 482.
The Diagnose and Feedback menu should allow you to access the logs which are in:
%LOCALAPPDATA%\Docker\log.txt
It will generate a zip file with said logs and other information.
The default recommendation is:
Reset to factory defaults (from the whale menu, Settings, reset)
If that doesn't work, manually uninstall docker and download the latest installer from https://docs.docker.com/docker-for-windows/
But sometimes, all the options in the "Reset" pane are grayed out.
For testing, desactivating the AV (AntiVirus) is an option (again, just to be tested).
Check also the state of your Network adapater in the device manager.
If you have a third-party network product like a VPN (for instance https://www.zerotier.com/), try and uninstall it before restarting docker.
Resetting Hyper-V could help:
Go to "Turn Windows features on or off", disable all Hyper-V related features, reboot, then Docker should ask if it can enable and reboot for you.
Let it do that and see if it's fixed. If not I'd probably try manually re-enabling Hyper-V.
Similarly:
I had a problem with most recent version. I uninstalled it, removed all docker folders and server and virtual switch from hyper-v and then reinstalled and it worked.
Check if you don't have some IP address already in use.
Finally, you can perform some Hyper-V tests.
This is what worked for me. In my case, docker uses WSL 2 instead of Hyper-V.
Type optionalfeatures in Windows search and hit Enter
Scroll down to Hyper-V. This checkbox was selected for me.
Deselect the checkbox and hit OK
Let Windows finish disabling the feature. When completed, hit Restart now
After restart, docker will start automatically very quickly
I also ran into this "Docker is starting..." problem on Win10 Enterprise version 22H2 with Docker Engine v20.10.22
I tried all of the top-rated comments, including uninstalling and reinstalling Docker, running wsl --unregister docker-desktop and wsl --unregister docker-desktop-data, deleting the Docker and Docker Desktop folders from AppData\Roaming\ etc. However, none of the solutions worked.
Instead, what eventually worked was running wsl --update in PowerShell. Note: Docker Desktop was not running when I tried this.
Work for me in powersheell in 17/10/2018
It looks like Hyper-V didn't get installed correctly either
Try to remove them, then install manually to see if that helps. Make sure you run powershell as an admin
Disable-WindowsOptionalFeature -FeatureName microsoft-hyper-v -online
(wait, sometimes until now you have decided, if not, continue)
restart-computer
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
restart-computer
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
or
run MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof in powershell
restarting the Hyper-V Management service
UPDATE
Looks like in Docker for Windows version: 17.09.0-ce-win33 (13620) they fixed the problem
This is an annoying problem that docker for Windows has. The latests versions have minimized it a lot but it still happens.
Check if docker for Windows will start when windows starts (this is the default behavior) if not check it.
Shutdown the machine. No restart. Shutdown.
Everytime you find this problem just shutdown the machine. The next time Windows boot docker will start very fast.
I know it looks esoteric but it works.
TLDR;
I have made a video that demonstrates fixing this: https://youtu.be/NHfqxx12kRs
TL;
I have the following Build Info:
Edition Windows 10 Pro
Version 22H2
Installed on ‎1/‎9/‎2021
OS build 19045.2075
Experience Windows Feature Experience Pack 120.2212.3920.0
These steps worked for me.
Step 1: Quit Docker Desktop
If your Docker desktop is open, then Quit and exit out of docker desktop
Step 2: Turn Windows Features on / Off
Ensure the following as shown below
Step 3: Install Ubuntu terminal environment with WSL
Launch Microsoft Store and search for wsl or Ubuntu. Install latest version of ubuntu as shown in screenshot.
Step 4: Enabling Docker support in WSL 2 distros
Now, Enabling Docker support in WSL 2 distros as mentioned here. Simply run the following commands in windows terminal:
wsl.exe -l -v
wsl.exe --set-default-version 2
wsl --set-default Ubuntu-22.04
For me the console looks like this.
C:\Users\tutlinks>wsl.exe -l -v
NAME STATE VERSION
* Ubuntu-22.04 Running 2
docker-desktop Stopped 2
docker-desktop-data Stopped 2
C:\Users\tutlinks>wsl.exe --set-default-version 2
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The operation completed successfully.
C:\Users\tutlinks>wsl --set-default Ubuntu-22.04
C:\Users\tutlinks>wsl.exe -l -v
NAME STATE VERSION
* Ubuntu-22.04 Running 2
docker-desktop Running 2
docker-desktop-data Running 2
Step 5: Launch Docker desktop
Launch the Docker Desktop and wait for the engine to start.
Just solved this issue.
Not sure if it would help in your case but for me it was the PATH env variable that was not set up properly. Checking the diagnostics logs I was getting "powershell not found" and "docker not found" etc
The solution for me was to add everything to the PATH environment variable:
%SystemRoot%\system32; // Stuff like bash, wsl
C:\Windows\System32\WindowsPowerShell\v1.0; // powershell itself
C:\Program Files\Docker\Docker\resources\bin; // docker-compose etc
// edit
C:\Program Files\Docker\Docker\resources // docker itself
It might vary for your setup though
I had the same problem and nothing above helps.
I typed
bcdedit /set hypervisorlaunchtype auto
and after that I restart my PC. After that docker starts normally :) Finally.
Restarted Docker Desktop in Admin mode and it worked for me.
I solved the issue by installing linux-sub-system for win 11.
Open up PowerShell then run this command to see if you have installed already:
wsl -l -v
If you have this message:
Run this command:
wsl --install
then you will get list of valid distributions can be installed:
Choose your distro, in my case I used Ubuntu-20.04:
wsl --install -d Ubuntu-20.04
Also needed to switch to WSL 2
links that can help:
Windows Subsystem For Linux has no Installed Distributions Error Fix
Upgrade version from WSL 1 to WSL 2
For anyone on Windows 10 Home, what worked for me was running
wsl --update
Running wsl --status revealed the WSL 2 kernel file was missing from my machine and instructed me to enable the Receive updates for other Microsoft products when you update Windows option under
Settings > Update & Security > Advanced options
The same problem on Win 10 Pro 22H2 (Docker Desktop 4.16.1). For me the solution was to temporary switch to Windows container and then switch back to Linux containers.
Windows 11 Pro x64
I've tried it with Container and Hyper-V's not installed but it still didn't work.
I have Container and all the Hyper-Vs enabled then ran these 3 codes as Administrator in CMD in order one-by-one and it works:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --set-default-version 2
If your internet is running behind proxy - you should enter proxy settings in "Proxies" tab of docker's configuration window - that worked for me.
Go to Exploit Protection >Program Settings
Disable CFG of both
1.C:\Windows\System32\vmwp.exe
2.C:\Windows\System32\vmcompute.exe
For mine it works when I got Task Manager-> Startup->Disable Docker
Open Docker and it will run.
Case 1: If one was able to run docker successfully at the start and this "Docker Desktop Starting" is occurring suddenly after unexpected shutdowns or other interruptions, this could be fixed by switching between Linux and Windows containers.
'''
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine
or
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine.
For the first case, you can also try to stop and restart docker services or uninstall and reinstall the docker application.
Case 2:
If Docker is not starting from the first time installation, this could be because you're system does not support or enabled hyper-v.
Understand one thing that is hard to discover, just enabling wsl 2 as backend for docker isn't enough as wsl itself relies on hyper-v for execution.
So check if you're system has hyper-v feature, if yes then enable it.
If not, follow these steps to install hyper-v manually:
Download the hyper-v.bat file for windows 10
Link: https://drive.google.com/file/d/1QT536aZMYSSj7rp766pv4YLpQaLcnB1F/view?usp=sharing
2: Open the hyper-v.bat file and the terminal screen will be displayed installing all hyper-v features.
3: Restart you're PC and go to Windows Features, Enable the hyper-v feature.
After this run the docker application making sure that wsl2 is already installed and updated.
you're docker will be in a running state if you don't have hyper-v but you've installed and enabled hyper-v through these steps.
As hyper-v features are pre-installed in windows enterprise and above version, finding out that the root cause of docker not starting was the absence of hyper-v, took me nearly two days to research.
I tried most of the top answers with no solution. Ended up with uninstalling and reinstalling docker and it worked.
Tried all solutions presented here with no success. This is the only solution that worked for me (from issue 1825).
In PowerShell, run:
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
I was struggling with this one and did all the steps mentioned above without success.
For me, it was that my BIOS required me to enable it through the motherboard's SVM option. Just make sure to restart your PC hit F2 or DEL and navigate and enable the SVM.
None of the existing answers work for me.
Go to Task Manager > Detail tab and kill every process that starts with wsl... (specially wslservice.exe)
I installed docker 4.16.2 and faced same issue. After following through many solutions, finally updating it to 4.16.3 works for me. Here's link to issue raised on official repo and solution suggested.
Comment providing 4.16.3 release candidate: https://github.com/docker/for-win/issues/13165#issuecomment-1405161605
Release Candidate (4.16.3 exe): https://desktop-stage.docker.com/win/main/amd64/96527/Docker%20Desktop%20Installer.exe
UPDATE
You can checkout official release here: https://docs.docker.com/desktop/release-notes/#4163
For me it was vmms service, that was disabled manually.
Check your ability to create virtual machines through powershell
Ctrl + Alt + Del => Task Manager => start up=> click on programs and click on disable => close task manager => Restart PC
If your docker takes forever to load the engine, just go to task manager and disable some running apps. It worked for me. Follow the steps
I got it working by:
stopping/killing everything in task manager that had the word "docker" in it.
unregistering all wsl2 distributions
install the WSL2 distribution I needed.
start docker desktop and wait about 5 minutes - success!
Powershell as admin:
wsl -l
Repeat for each distribution
wsl --unregister <name of distribution>
Install the one you require
wsl --install -d <name of distribution>
Enable VM platform and update wsl solve my issue:
Search turn Windows features on or off > tick Virtual Machine Platform checkbox
Run command prompt with adminstrator mode, and execute wsl --update
After restarting system, I am able to run docker.

Resources