在 Ubuntu/WSL 上运行 docker 时出现“无法连接到 Docker 守护进程...”

Yaf*_*faa 3 lubuntu docker windows-subsystem-for-linux

我尝试使用命令在 WSL (Windows 10) 中运行 docker sudo service docker start,它显示:

 Starting Docker: docker
Run Code Online (Sandbox Code Playgroud)

但当我跑步时sudo docker images,它告诉我:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Run Code Online (Sandbox Code Playgroud)

关于如何解决这个问题有什么想法吗?

小智 8

它来自使用的 nftables 而不是 iptables

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
从这些线程中找到了这个解决方案:
https://github.com/microsoft/WSL/discussions/4872
https://patrickwu.space/2021/03/09/wsl-solution-to -native-docker-daemon-未启动/