WSL DETECTED: We recommend using Docker Desktop for Windows

背景

已经配置好了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.04Apply&Restart

激活wsl2与docker的集成

后续问题

发现无法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)
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Windows系统中,可以通过安装WSLWindows Subsystem for Linux)来使用DockerWSL是一种允许在Windows上运行Linux发行版的技术。在使用WSL时,我们可以通过命令行界面来操作Linux发行版,这使得在Windows系统上进行Linux开发变得更加方便。 要在WSL中使用Docker,我们需要首先安装适当的Linux发行版。对于大多数用户而言,推荐使用官方提供的Docker Desktop,它包含了WSL2发行版以及Docker引擎。使用Docker Desktop可以方便地进行Docker容器的构建、部署和管理。 为了开始在WSL中使用Docker Desktop,我们需要按照以下步骤进行配置: 1. 首先,确保你的Windows系统版本是支持WSL2的,可以通过在命令行中运行"winver"命令来查看Windows版本号。如果版本较低,需要更新到较新的Windows版本。 2. 下载并安装Docker Desktop。在Docker官方网站上可以找到适用于Windows的安装程序。安装过程很简单,只需按照提示进行操作即可。 3. 安装完成后,打开Docker Desktop应用程序。在设置中,选择“WSL Integration”,启用WSL2,并选择要用于DockerWSL发行版。这里我们选择“docker-desktop”作为我们的WSL发行版。 4. 确认配置后,Docker Desktop将会自动为我们配置WSL并启动相关服务。这样,我们就可以在WSL中直接使用Docker命令了。 完成上述步骤后,我们就可以在WSL中使用Docker来构建和运行容器了。可以通过在WSL终端中运行"Docker run"等命令,来创建和管理容器。 总之,通过在WSL中配置和使用Docker Desktop,我们可以在Windows系统上轻松地进行Linux容器化开发。这为开发者提供了更加便捷和灵活的开发环境,同时还能充分利用Windows和Linux的优势。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值