重装docker后wsl2里无法使用docker命令:手动添加wsl2集成的方法
参考报错
Ubuntu 24:
$ docker ps -a
The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.
Ubuntu 22:
$ docker ps -a
failed to connect to the docker API at unix:///var/run/docker.sock;
dial unix /var/run/docker.sock: connect: no such file or directory
解决方法
方法一:图形界面
Docker Desktop → Settings
方法二:改配置文件
- 编辑
C:\Users\mchao\AppData\Roaming\Docker\settings-store.json,加入:
"IntegratedWslDistros": ["Ubuntu-22.04", "Ubuntu-24.04"]
评论