Developing in devcontainer: How to access local network of host

I just finished creating a new dev environment in VSCode devcontainer according to this documentation:

Starting and debugging works fine.
But now the container cannot access my network devices which I need to implement the integration.

My host PC is Windows 10 on network 192.168.1.x. My network device which I need to access is on How do I need to configure the devcontainer to allow it to connect to the specified address?

Hopefully you managed to figure this out some time in the past several months - but I’ve just had to figure this out as I was in a similar situation. In case anyone else finds this thread while hunting for an answer, here’s what I’ve figured out:

  1. Edit .devcontainer/devcontainer.json and add "--network=host" to the runArgs array
  2. Rebuild your dev container (command palette → Remote Containers: Rebuild Container)
  3. (re)Start Home Assistant (command palette → Tasks: Run Task → Run Home Assistant Core)

Your dev container should then be connected to your host network.

1 Like

Thanks, but this doesn’t work for docker in windows.

I am using Windows Subsystem for Linux (WSL) installation method and I have full access to host network, without any specific action.