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

21

17

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

  • Windows 10
  • Docker Desktop 4.6.1
  • WSL 2
  • List item
  • .wslconfig (memory=8GB, processors=4)

I have tried following patterns to make it run

  • restarted docker and windows many times
  • done with wsl upgrade > sudo apt update && sudo apt upgrade -y
Bowden answered 28/3, 2022 at 8:54 Comment(2)
Is the Ubuntu WSL distribution running fine otherwise (the last bullet indicates that it is)? Typically this error will occur when the distribution terminates. Also, have you changed anything in your shell startup scripts recently? Not running Systemd, right? After this error occurs, is the Ubuntu/WSL distribution still running (wsl -l -v from PowerShell)?Miterwort
Wondering if this problem resolved itself for you. It sounds now to me like it could have been caused by the bug mentioned in this Ask Ubuntu question, especially since you mention specifically using the "Ubuntu 20.04" distro. The problem was quickly resolved for most people with a new version pushed by Canonical, which I would assume would have happened for you. For those unlucky few that first installed when the bug was in place, the "fix" broke things for them, though.Miterwort
B
11

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!

Brilliant answered 21/4, 2022 at 12:48 Comment(4)
This answer is from: github.com/docker/for-win/issues/9972#issuecomment-756900017Oleary
I can't open docker desktop setting, it's also loading forever :(Brandi
Skipping to step 3 (since docker desktop was entirely frozen up) also worked for me. Also docker started by itself at launch so step 7-8 was also not necessaryAnonym
The "Enter to Settings -> Apps and search for ubuntu" point refers to the Windows Settings app. For me it wasn't obvious, as I didn't know that there is a dedicated Settings app besides control panelRepresentation
H
15

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

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

Handwork answered 15/4, 2023 at 0:37 Comment(1)
This worked for me where nothing else worked. It deleted all the images and containers i had thoughClarettaclarette
O
14

Check for a system variable

Path - C:\Windows\System32

Maybe it will save you a few hours.

Osculum answered 20/12, 2022 at 16:23 Comment(3)
I can't believe this was the actual problem for me! I was cleaning out my %PATH% variable since it had grown too large and had removed some duplicates. I removed C:\Windows\System32 because %SystemRoot%\System32 was already there, but apparently the variable expansion doesn't work correctly in Docker Desktop.Infidelity
I upvote but this answer was not clear enough IMHO. This solution was the solution for a colleague. For some reason his Path variable went corrupted, so just ensure your Path variable (User and System) at least has the minimum entries : computerhope.com/issues/ch000088.htmSamphire
This worked for me but the answer not clear- Open the Start menu and search for "Environment Variables." Click "Edit the system environment variables." In the System Properties window, click "Environment Variables." Under the "System variables" section, select the "Path" variable. Click "Edit" to modify the "Path" variable. In the "Edit Environment Variable" window, check if "C:\Windows\System32" is listed. If not, click "New" and add it manually (separate multiple entries with a semicolon). Click "OK" to save the changes.Interpolation
B
11

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!

Brilliant answered 21/4, 2022 at 12:48 Comment(4)
This answer is from: github.com/docker/for-win/issues/9972#issuecomment-756900017Oleary
I can't open docker desktop setting, it's also loading forever :(Brandi
Skipping to step 3 (since docker desktop was entirely frozen up) also worked for me. Also docker started by itself at launch so step 7-8 was also not necessaryAnonym
The "Enter to Settings -> Apps and search for ubuntu" point refers to the Windows Settings app. For me it wasn't obvious, as I didn't know that there is a dedicated Settings app besides control panelRepresentation
K
4

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.

Kimi answered 9/2, 2023 at 17:17 Comment(2)
That's the solution right there. I was working on a project which I had to simulate a serial connection and I used /dev/pts/<pts_number> and pts was created randomly, so it was mounted on mount.data but it was never created on WSLHallsy
This was the issue, seems like my bad mount was caused by phpstorm, I just had to delete the phpstorm line by doing "sudo vim mounts.data" from my ubuntu console and that got it started right away, Thank you!Radiopaque
K
3

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.

Karelia answered 15/9, 2022 at 7:11 Comment(1)
In my case just apt update upgrade is resolve problemTuinenga
H
2

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

Harm answered 27/4, 2022 at 2:46 Comment(0)
N
2

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.

Nofretete answered 4/10, 2022 at 7:28 Comment(0)
A
2

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.

Abracadabra answered 2/10, 2023 at 6:2 Comment(2)
Thanks, chown worked for me, in my case I run sudo chown -R <<username>>: /home/<<username>>Zyrian
Oh that was a typo my bad. Yes chown is correct. I'll update my answer. Thanks!Abracadabra
O
1

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.

Osmometer answered 19/7 at 22:36 Comment(1)
Thank you! This pointed me in the right direction-- my WSL had been updated to version 2.3.11 as well. However, I found a quicker/easier solution in the related WSL github issues that doesn't require rolling back to the older version, you just need to enable systemd: https://mcmap.net/q/687365/-docker-wsl-2-integration-with-distro-ubuntu-20-04-unexpectedly-stopped-with-exit-code-1International
I
1

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!

International answered 22/7 at 12:51 Comment(0)
E
0

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.

Entanglement answered 12/10, 2022 at 6:25 Comment(0)
L
0

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
Lactose answered 12/4, 2023 at 12:12 Comment(0)
I
0

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
Iceberg answered 14/4, 2023 at 11:48 Comment(0)
R
0

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>

Ruthenic answered 13/2 at 18:45 Comment(0)
T
0

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.

Throckmorton answered 3/3 at 18:27 Comment(1)
I'm glad you fixed your problem, but this isn't likely to be the solution for most users.Miterwort
R
0

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.

Robins answered 17/3 at 16:49 Comment(0)
A
0

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

Anticathode answered 2/6 at 12:41 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.Rabia
B
0

i did on powershell as admin :

  1. sc.exe config wslservice start= demand
  2. wsl --install
Butterfish answered 27/6 at 1:7 Comment(0)
Q
0

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

Quadricycle answered 15/7 at 6:38 Comment(0)
R
0

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...

Rubie answered 18/7 at 11:12 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewSwab
E
0

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.

Ema answered 24/7 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.