修復 Docker Desktop for Windows 升級後的 WSL integration 錯誤

Posted by Y Cheung on Wed, Feb 19, 2025

Windows 10 上的 Docker Desktop 最近升級至 v4.38.0 後突然冒出了 WSL 錯誤。

Docker Desktop WSL integration with distro Legacy unexpectedly stopped
running wsl distro proxy in Legacy distro: running proxy: exit status 1

嘗試了 Restart the WSL integration 和 Skip Legacy WSL distro 都不行,問 AI 可能的原因是:

  • Proxy Configuration Issues: If you’re using a proxy, incorrect settings can lead to failures in establishing connections, which might cause the exit status 1 error. This can happen if environment variables like HTTP_PROXY or NO_PROXY are not set correctly.
  • WSL Version Compatibility: Running an older version of WSL (like WSL 1) can lead to compatibility issues with certain applications or configurations, especially when using Docker or other services that rely on network connectivity.
  • Systemd Not Running: In WSL, systemd is not enabled by default, which can lead to issues when trying to manage services that expect it to be present. This is particularly relevant for applications like Docker that may require it for proper initialization and management.
  • Corrupted WSL Filesystem: A corrupted filesystem in your WSL installation can also cause unexpected terminations and errors. Running a filesystem check may resolve this issue.

結合 Y Cheung 的實際情況,估計可能是WSL版本問題了,於是在Powershell中 wsl --update 隨手更新了一波 WSL。

更新後重啟 Docker Desktop for Windows 又彈出錯誤警告窗口,這次錯誤信息提示變了。

Docker Desktop WSL integration with distro Legacy unexpectedly stopped again
retrieving homedir for Legacy distro: getting home folder for Legacy distro: running echo $HOME in Legacy: sending to distro: write |1: The pipe is being closed.

繼續丟去問 AI ,得到的回复是:

  • Renamed Home Directory: If you’ve recently renamed your home directory, Docker Desktop might be looking for the old directory, causing issues.
  • WSL Issues/Corruption: An unexpected error during WSL command execution, possibly due to access rights issues after waking the computer. WSL distro terminated abruptly.
  • Docker Installation on a Different Drive: Installing Docker Desktop on a drive other than the default can cause WSL-related errors.
  • Conflicting CLI Plugins: Problems with CLI plugins can interfere with Docker’s operation.
  • Home Assistant and File Permissions: While this search result relates to Home Assistant, it highlights potential permission issues that can prevent Docker from creating necessary directories.
  • Corrupted Docker Configuration: A corrupted Docker configuration can cause startup issues.

額,感覺不是很靠譜。用 wsl -l -v 命令查看了下當前的狀態是:

1  NAME              STATE           VERSION
2* Legacy            Stopped         1
3  docker-desktop    Running         2

wsl --set-version Legacy 2 嘗試將 Legacy 的版本設置為2,結果被拒絕,說是舊分發不支持 WSL 2. 錯誤代碼: Wsl/Service/WSL_E_VM_MODE_NOT_SUPPORTED 喔~

沒辦法,遇事不決,先嘗試重啟系統吧!

重啟系統也沒辦法解決,這…… 大概 Y Cheung 還沒學會怎麼跟 AI 溝通吧,轉回用老辦法 Google 一通,看過 WSL 文檔1與部分網友的建議2,Y Cheung 重新安裝了 WSL,並將原來的 Lagacy 註銷,就解決了。

1# 安裝 WSL 2
2wsl --install
3
4# 註銷 Lagacy
5wsl --unregister Legacy

相關問題參考: