在 vscode 开发容器中,有没有办法从本地网络上的不同机器访问 docker 容器?

In a vscode development container, is there a way to access the docker container from a different machine on the local network?

我有一个应用程序 (sveltekit) 运行,我想从本地网络上的其他设备访问它。

可以从localhost:3000.

上的主机正常访问它

想要以某种方式从本地网络上的另一台机器访问它。这可能吗? Sveltekit cli 有 --host 标志,输出如下:

$ svelte-kit dev --host

local:   http://localhost:3000
network: http://172.17.0.3:3000

如何从本地网络上的其他设备访问该网络url?

OS: Pop OS
VSCode: 1.63.0 
Docker: Latest stable version.

Docker Installed using repository. Running in rootless mode.

所需要的只是 以下 VSCode 设置。默认情况下,它被设置为“localhost”。将其设置为“allInterfaces”可授予对本地网络上其他设备的访问权限。

// settings.json

"remote.localPortHost": "allInterfaces"

然后,在连接到同一 wifi 网络的另一台设备上,使用以下 URL:

Format: <your-local-ip>:3000
Example: 192.168.1.105:3000

注意:在这种情况下,不需要将 --host 传递给 sveltekit cli。 VSCode 似乎正在处理这个问题。