记一次wsl2+docker无法运行的经历
前情提要
由于某个大创项目的需要和对猫娘机器人的迫切渴求(bushi 需要在电脑里面安装docker desktop。由于电脑里面安装了wsl2环境 因此决定使用wsl2+dockerdesktop的方式配置docker
遇到的问题
在像往常一样安装docker desktop并且启动时 提示错误:
running engine: waiting for the Docker API: engine linux/wsl failed to run:
starting WSL engine:
error spotted in wslbootstrap log:
"[2025-03-21T13:07:10.372236810Z][wsl-bootstrap][F] exit status 32"
或者错误:
deploying WSL2 distributions
ensuring main distro is deployed: checking if main distro is up to date: checking main distro bootstrap version:
getting main distro bootstrap version:
open \\wsl$\docker-desktop\etc\wsl_bootstrap_version: The network name cannot be found.
checking if isocache exists: CreateFile \\wsl$\docker-desktop-data\isocache\: The network name cannot be found.
解决方案
尝试了网上给出的许多方法 比如 wsl --unregister docker-desktop
卸载重装docker-desktop 重新安装服务等等等等
最终发现:如果你自己编译了wsl的内核,在.wslconfig 删除加载这个内核即可解决
发现问题的原始issue https://github.com/microsoft/WSL/issues/11771
可能的原因:在内核构建流程中未打开部分功能
解决方案:
- 若你没有自定义内核的需求,删除自定义内核配置即可
- 若你存在自定义内核的需求,在
https://github.com/user-attachments/files/17561192/config-wsl-6.6.36.6.txt
这一配置上修改 - 若你需要高度自定义内核 则修改以下配置从
m
到y
CONFIG_BRIDGE=y
CONFIG_BRIDGE_NETFILTER=y
CONFIG_NFT_COMPAT= y CONFIG_NETFILTER_XT_NAT
=y
CONFIG_NETFILTER_XT_TARGET_MASQUERADE=y
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
相关的话
由于这个问题是docker的问题 若你在wsl里面使用docker而非使用docker desktop也可能遇到这个问题