wsl2中安装完docker,使用启动命令
sudo service docker start提示docker在启动,但是使用命令
docker ps后仍然提示
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?原因:
通过系统工具update-alternatives 可以配置和切换当前系统中的iptables 环境做到多版本管理。
 切换iptables版本解决WSL2中docker运行异常的问题。
解决办法:
查看当前配置信息
$ sudo update-alternatives --config iptablesThere are 2 choices for the alternative iptables (providing /usr/sbin/iptables).Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/sbin/iptables-nft      20        auto mode1            /usr/sbin/iptables-legacy   10        manual mode2            /usr/sbin/iptables-nft      20        manual modePress <enter> to keep the current choice[*], or type se