当我启动第一个 WSL 终端(在我的例子中是 ubuntu 20.04 bash)时,WSL 会/etc/hosts
根据我的 windows 系统的主机文件生成文件%WINDIR%\System32\drivers\etc\hosts
。
如果我现在更改%WINDIR%\System32\drivers\etc\hosts
,例如添加一些条目,/etc/hosts
则不会更新我的 WSL 中的 。即使我关闭所有 WSL 终端并打开一个新终端。只有重新启动我的 Windows 系统才有帮助。
有没有办法可以手动触发更新,/etc/hosts
这样我就不必重新启动?
我尝试按照本教程运行嵌套在 WSL 2 中的 KVM,但是在按照说明编译内核并加载内核后,测试kvm-ok
报告不支持 KVM。
我尝试了多个选项:启用 hyper-v、禁用它、验证 BIOS/CPU 支持、启用/禁用 Device Guard、某些vmware 文档中的其他步骤(bcdedit /set hypervisorlaunchtype、gpedit/DeviceGuard 下的子选项)。
当我禁用 hyper-v、将 hypervisorlaunchtype 设置为关闭并禁用 Device Guard 时,我会在系统信息中看到以下选项,但随后 wsl2 根本无法启动,并显示“请启用虚拟机平台 Windows 功能并确保虚拟化已启用”在 BIOS 中启用。”
我尝试的任何其他配置,sys info 都会显示虚拟机管理程序正在运行并且不会显示 hyper-v 值,但我最终遇到了 WSL2 不支持 KVM 的初始问题。此外,如果我尝试在 VMWare Player 中启用“虚拟化 Intel VT-x/EPT”,也无法启动。
退一步来说,最终我想做的是在我的 Windows 笔记本电脑上运行firecracker 演示。因此,如果有更简单的方法可以做到这一点,那么 lmk 。
我注意到它可以在带有 Ubuntu 映像的 VMWare Player 中运行。或者至少,kvm-ok 报告它已启用,/dev/kvm 存在。我还是宁愿使用 WSL2。但它拒绝加载。
我尝试通过 Windows 浏览器访问它,但失败了。我的错误是什么?
我在 Windows 10 和 ubuntu 20 上使用 WSL2。
我有一个 apache 服务器和一个 laravel 应用程序,我安装在/var/www/law
Windows 主机文件中,我添加了以下内容:
127.0.0.1 law.dev
::1 law.dev
Run Code Online (Sandbox Code Playgroud)
这是law.conf
位于 的文件/etc/apache2/sites-available
。
<VirtualHost *:80>
ServerName law.dev
DocumentRoot /var/www/law/public
<Directory /var/www/law>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud) 我的 Windows 机器上运行着 Postgres,我需要从 WSL2 内部连接到它。
psql
172.31.210.120
,网络掩码255.255.240.0
(使用 确定ipfconfig
)。172.31.208.1
(使用 确定cat /etc/resolv.conf
)curl http://172.31.208.1:8080
. 如果我记录传入请求的 IP,我会得到172.31.210.120
这验证两个 IP 是否正确。pg_hba.conf
:host all all 172.31.210.120/20 scram-sha-256
如果我尝试使用以下命令从 WSL 连接到它:
$ psql --host=172.31.208.1 --port=5432 --user=postgres
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
psql: error: could not connect to server: could not connect to server: Connection …
Run Code Online (Sandbox Code Playgroud) 重新配置 PC 后,我无法正确使用 Docker,因为某些curl 命令由于 SSL/TLS 问题而被拒绝。
仅在一个示例中curl -vfsSL https://apt.releases.hashicorp.com/gpg
返回以下错误:
* Trying 52.222.214.125:443...
* TCP_NODELAY set
* Connected to apt.releases.hashicorp.com (52.222.214.125) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* …
Run Code Online (Sandbox Code Playgroud) 上网搜索发现,在 Windows 10 2004 版中,WSL2(Windows Subsystem for Linux,v2)现已普遍可用。我用它,它很棒。
我能够找到的有关 Windows Server 的所有信息(截至 2020 年 9 月)表明 WSL2 仍然仅在内部预览版本中可用。我无法找到任何关于何时可以在非内部版本的 Windows Server 中使用它的信息
Microsoft 是否已公开此信息?如果是这样,我需要哪个版本的 Windows Server,何时可用?
我的主机上正在运行 selenium,我的应用程序位于 docker 容器内(在 WSL2 内)。
我正在尝试让应用程序连接到 selenium,它正在监听端口 4445。几个月前它曾经工作过,我认为 WSL 中发生了一些变化。
主机正在监听 4445:
PS> netstat -ano | findstr :4445
TCP 0.0.0.0:4445 0.0.0.0:0 LISTENING 11604
TCP [::]:4445 [::]:0 LISTENING 11604
Run Code Online (Sandbox Code Playgroud)
我可以从Windows主机访问selenium:
>curl -X POST http://DESKTOP-HED9HVG:4445/wd/hub
{"state":".....}
Run Code Online (Sandbox Code Playgroud)
但不是来自 WSL2:
$ curl -X POST http://172.22.241.214:4445/wd/hub
curl: (7) Failed to connect to 172.22.241.214 port 4445: Connection refused
Run Code Online (Sandbox Code Playgroud)
我尝试了在curl中使用的ip的几个选项:
ip addr
eth0 ip$(hostname)
ipconfig /all | findstr IPv4
route -n | grep UG | head -n1 | awk '{print $2}'
我在 …
我的系统是带有 WSL2 的 Win10,我运行了一个 dockergogs
容器(来自 WSL 中的 ubuntu):
83b2a8833235 gogs/gogs "/app/gogs/docker/st…" 17 minutes ago Up 17 minutes 0.0.0.0:10022->22/tcp, :::10022->22/tcp, 0.0.0.0:10080->3000/tcp, :::10080->3000/tcp gogs
Run Code Online (Sandbox Code Playgroud)
我发现我可以卷曲它,但不能使用浏览器访问它:
>curl -vvv http://localhost:10080
* Rebuilt URL to: http://localhost:10080/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 10080 (#0)
> GET / HTTP/1.1
> Host: localhost:10080
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Content-Type: text/html; charset=utf-8
< Location: /install
< Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
< Set-Cookie: i_like_gogs=64602dcbf733a9e0; …
Run Code Online (Sandbox Code Playgroud) windows-subsystem-for-linux ×8
curl ×2
ubuntu ×2
hosts ×1
hosts-file ×1
hyper-v ×1
linux ×1
netstat ×1
postgresql ×1
ssl ×1
virtualhost ×1
windows ×1
windows-10 ×1