Muhammad Muzamil
Muhammad Muzamil

Reputation: 1282

Docker: WSL 2 integration with distro Ubuntu 20.04 unexpectedly stopped with exit code 1

My docker environment was working fine. I restarted my system and it stopped unexpectedly. whenever I try to start docker it throws the following error

WSL 2 integration with distro Ubuntu 20.04 unexpectedly stopped with exit code 1.

I am using the following versions

I have tried following patterns to make it run

Upvotes: 29

Views: 69652

Answers (24)

Seun S. Lawal
Seun S. Lawal

Reputation: 611

Here's what worked for me after try almost every suggesstion above without success.

I checked docker desktop Settings -> Resources -> WSL Integration, and found there was no distribution listed.

Next step is to confirm what distributions I have installed and what version they were. Using wsl.exe -l -v in windows terminal will help you do that.

From the list I found that my Ubuntu-24.04 was listed as Version 1.

Then, I ran this command to upgrade it to version 2.

wsl.exe --set-version Ubuntu-24.04 2

Took a few minutes and it was done.

I returned to Docker desktop settings under Wsl Integration, and refreshed the distros list.

Now, I can see the Ubuntu listed here. All I did here was to toggle it on, and clicked apply.

That solved the issue for me.

Upvotes: 13

emeka
emeka

Reputation: 21

After upgrading to v4.37.1 and facing this same issue, I ran wsl --update

Still facing the same issue, I unchecked 'Enable integration with my default distro"

My Docker displays : "You don't have any WSL 2 distros installed. Please convert a WSL 1 distro to WSL 2, or install a new distro and it will appear here."

Upvotes: 0

Sohaib Ahmad
Sohaib Ahmad

Reputation: 34

If you encounter the same issue, and after trying every solution from the internet, the problem persisted, then all you need to do is update Docker Desktop, and it will run flawlessly issue in this image

Upvotes: 0

VooDooTo
VooDooTo

Reputation: 1

I have also removed C:/Windows/System32 from the Path variables and this has caused this problem to me. Try to add the folder "C:/Windows/System32" to PATH and try again starting the Ubuntu distribution and also Docker Engine will be able to start again.

Upvotes: 0

James_Crumble
James_Crumble

Reputation: 24

For someone who cannot found any solutions. My problem was unabled to access to wsl network system from windows expolorer directly but powershell wsl command nicely

https://learn.microsoft.com/en-us/answers/questions/602778/windows-11-does-not-read-linux-tree

link info ref (

The solution was to use the Registry Editor (regedit.msc) to edit

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order

and change it to

P9NP,cbfsconnect2017,RDPNP,LanmanWorkstation,webclient,wsauth

)

After that problem was solved for me...

Upvotes: 0

Ziad Akiki
Ziad Akiki

Reputation: 2680

Contrary to other answers, my issue was due to a buggy WSL update (a pre-release version). Rolling back to an older version resolved the issue:

  1. Quit Docker Desktop. You might need to kill everything related to it from the Task Manager if it has been stuck on an error or loading forever.
  2. Check the version you have for wsl using: wsl --version. For example, at the time of writing, version 2.3.11 was problematic and a revert back to 2.2.4 was necessary.
  3. Uninstall wsl using the following command: wsl --uninstall. You will not loose your distros.
  4. Go to the official WSL release website and install a previous version: https://github.com/microsoft/WSL/releases. You will need the store bundle .msixbundle unless you had previously installed it manually using a normal installer.
  5. Launch the downloaded bundle and Install WSL again.
  6. Once complete, run Docker Desktop as an administrator, it should now start normally.

You may use this answer in combination with other ones here if needed but this should be enough.

Edit: Try the solution provided by @AndrewKeller below as it might save you from the hustle of reverting back to an older version.

Upvotes: 1

Andrew Keller
Andrew Keller

Reputation: 3239

Thanks to @Ziad Akiki for pointing me in the right direction with his answer. I confirmed that my WSL too had been upgraded to 2.3.11.0, but after digging through a few of the related issues on the WSL github I found this solution, which fixed the issue for me by enabling systemd without requiring rolling back to an older version. I shutdown Docker Desktop before following these steps.

  1. Enter wsl if you haven't already with the command wsl
  2. Edit the file /etc/wsl.conf (it may not exist): sudo vi /etc/wsl.conf
  3. Add the following (press i to insert first):
[boot]
systemd=true
  1. Write the changes (esc then :wq)
  2. Exit wsl: exit
  3. Shutdown wsl: wsl --shutdown
  4. Start wsl again: wsl

Docker desktop should now be able to start again!

Upvotes: 1

ppp
ppp

Reputation: 1

I got this problem due to local firewall, disabling the firewall solved the issue.

Upvotes: 0

Kerby Elpenord
Kerby Elpenord

Reputation: 205

i did on powershell as admin :

  1. sc.exe config wslservice start= demand
  2. wsl --install

Upvotes: 0

Jens
Jens

Reputation: 31

I had byobu enabled (on Ubuntu-24.04). Running byobu-disable immediately solved the issue with Docker Desktop integration.

Upvotes: 0

Logan G
Logan G

Reputation: 1

tldr: Turn off Resource Saver when debugging

I hope this helps someone avoid my pain...

While debugging the issue above, matter what I did,docker ps would output

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/

Then I turned off Resources->Advanced->Resource Saver in docker desktop and it fixed it. Screenshot of Docker Desktop settings menu

My underlying issue was similar to Manuel Pacheco mounts, but when debugging with no containers running I found that Resource Saver would cause docker ps not to work even after I removed the mounts file.

Upvotes: 0

Haitam-Elgharras
Haitam-Elgharras

Reputation: 138

In Docker Desktop Settings:

  1. Go to Resources -> WSL integration
  2. Enable integration with additional distros
  3. Select Apply & restart

If you get the error again just keep clicking restart.

Upvotes: 0

lMagickl
lMagickl

Reputation: 1

My situation was that I move my WSL ext4.vhdx file to another PC. To resolve this issue I had to set a default user to WSL using this command because by default its root :

ubuntu config --default-user <username>

Upvotes: 0

david2278
david2278

Reputation: 434

My user folder had root:root ownership.

I ran sudo chown -R david:david david (david is my username). So it was a permission issue.

Seems like there's a lot of reasons why this happens.

Upvotes: 2

wardvisual
wardvisual

Reputation: 330

Try these commands if you're willing to risk losing the data:

wsl --unregister docker-desktop
wsl --unregister docker-desktop-data

Upvotes: 26

Eugene M.
Eugene M.

Reputation: 1

I had the exact same error when Docker desktop was attempting to start.

Below are some attempts I made to resolve the issue with no outcome:

  1. Try restart WSL2 - wsl --shutdown
  2. Try update WSL2 - wsl --update & wsl.exe --update --pre-release
  3. Restarting windows
  4. Updating windows (lol)
  5. Restarting the LsxxManager - Get-Service LxssManager | Restart-Service
  6. Literally every solution shared here

NB: All the above commands were run in Powershell with administrative rights.

After 2 days, this worked for me.

Solution: I removed the .wslconfig file I added to the path C:\Users\<username>

I added this file to limit the insane amounts of memory Docker was consuming on WSL2. More details here

After I updated Docker to v4.18.0 it appears that the applied memory allocation constrained the new update from launching. Once I deleted the .wslconfig file, Docker started smoothly.

Version details for my machine:

  • Windows: 10 Pro - Version 22H2 (OS Build 19045.2846)
  • WSL2: 1.2.1.0
  • Docker: v4.18.0

Upvotes: 0

TrojanName
TrojanName

Reputation: 5385

This has happened to me a few times, and in many cases it was because I needed to update to a new version of WSL e.g. run the following in Powershell:

PS C:\Users\Me> wsl --update
Checking for updates.
Updating Windows Subsystem for Linux.
PS C:\Users\Me> wsl -v -l
WSL version: 1.2.0.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.2728

Upvotes: 1

Manuel Pacheco
Manuel Pacheco

Reputation: 41

Just posting what worked for me. I was using a WSL distro that I restored from a previous Windows installation (named here ubuntu-restore).

Initially, I was able to get more information to debug my problem by running:

sudo /mnt/wsl/docker-desktop/docker-desktop-user-distro proxy --distro-name ubuntu-restore

And the console gave the following error (simplified):

[docker-desktop-user-distro in ubuntu-restore][I] mounting /mnt/c/Users/no-longer-exists to /mnt/wsl/docker-desktop-bind-mounts/ubuntu-restore/b34c91da7c9e60d4983f67b84fe84fda955dbf79d010eb25ab0aaec28012fb5c
[docker-desktop-user-distro in ubuntu-restore][W] restoreMounts: ensure ready failed: mkdir /mnt/c/Users/no-longer-exists: permission denied

Which meant I had to clean up some old bind mounts that stayed in the distro. I found them in /var/lib/docker-desktop/mounts.data, removed them, and the WSL integration works again.

Upvotes: 4

Check for a system variable

Path - C:\Windows\System32

Maybe it will save you a few hours.

Upvotes: 14

Ganesh Ganiga
Ganesh Ganiga

Reputation: 1

I tried every answer here but when I'm starting docker was still facing the same issue.

So I started the docker without WSL after installation, then changed the setting to use WSL. Docker is working fine now. Hope this helps someone.

Upvotes: 0

Igor
Igor

Reputation: 41

Have the same problem. It solved after I add 'C:\Windows\System32' to path.

Try type wsl.exe or wslconfig.exe /l. If nothing happens than modify the path.

Upvotes: 2

gbro3n
gbro3n

Reputation: 6967

Unfortunately none of the solutions here worked for me. Steps to fix were:

  1. Update WSL2 Ubuntu distro:
sudo apt update
sudo apt upgrade
  1. Uninstall Docker Desktop on Windows
  2. Reinstall Docker Desktop on Windows

Note that containers and volumes were lost with the uninstall.

Upvotes: 6

ISMAIL BOUADDI
ISMAIL BOUADDI

Reputation: 343

I had the same issue when updated docker desktop with WSL2 backed has a work around I did the following steps:

  1. In docker desktop settings i enabled again the "enabled integration with other distros"
  2. Apply and restart the changes then stop Docker desktop.
  3. Enter to Settings -> Apps and search for ubuntu
  4. Click on Ubuntu and advanced settings
  5. Select repair
  6. Restart the computer
  7. After computer starts enter to the ubuntu wsl via console or terminal
  8. Start docker desktop
  9. Try docker ps or docker-compose to check if the error was resolved.

Hope this helps!

Upvotes: 17

Kellen
Kellen

Reputation: 159

Please try this solution comes from todpale:

  1. close Docker Desktop
  2. restart Ubuntu through services.msc or this command (you can put in bat): net stop LxssManager && net start LxssManager
  3. start Docker again

You also may check if your distro is enabled in Docker settings (General tab and Resources tab -> WSL Integration).

There is a discussion about this issue on Github https://github.com/docker/for-win/issues/9972

Upvotes: 3

Related Questions