Access VS Code Dev Containers from your local network
Dominik Rüttiger 1 min read
There are two ways to publish ports to the host and make them available on the local network: Forwarding and publishing.
This is a specific VS Code concept. The idea is that forwarded ports look like
localhost to the container. That makes it pretty easy to set up:
- Reload the VS Code window
This is just plain Docker:
"appPort": [ "4321" ],
- Adjust the scripts in the
package.jsonto make processes listen to all addresses. For Astro, for example, this would be:
"start": "astro dev --host"
- Rebuild Dev Container
GitHub Codespaces does automatic forwarding for us, without the need to configure any of the settings mentioned above.
Browser support: If you are wondering why your application preview won’t show up in Chromium: It just does not work at the moment.
The officially supported browsers are Chrome, Edge, Firefox and Safari.
Twitter Hacker News Reddit