背景
已经配置好了wsl2和docker desktop,因C盘空间不够卸载了Ubuntu20.04,后来又重新安装了Ubuntu20.04(nVidia-docker需要)
问题
可以在powershell下使用docker,但是不能在Ubuntu下运行,提示如下
$ docker
Command 'docker' not found, but can be installed with:
sudo apt install docker.io
$ sudo apt install docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package docker.io is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'docker.io' has no installation candidate
$ curl https://get.docker.com | sh
# Executing docker install script, commit: 7cae5f8b0decc17d6571f9f52eb840fbc13b2737
WSL DETECTED: We recommend using Docker Desktop for Windows.
Please get Docker Desktop from https://www.docker.com/products/docker-desktop
You may press Ctrl+C now to abort this script.
+ sleep 20
解决方法
打开docker desktop
,进入Settings > Resources > WSL Integration
,激活Enable integration with additional distros:Ubuntu-20.04
,Apply&Restart
。
后续问题
发现无法ping通外网,解决办法如下
wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
netsh winsock reset
shutdown /r ```
# 参考
[Docker Desktop WSL 2 backend](https://docs.docker.com/docker-for-windows/wsl/)
[none of this helped but answer on stackoverflow helped](https://github.com/microsoft/WSL/issues/4275)
[No internet connection on WSL Ubuntu (Windows Subsystem for Linux)](https://stackoverflow.com/questions/62314789/no-internet-connection-on-wsl-ubuntu-windows-subsystem-for-linux/64057835#64057835)