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.


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.

I’m getting crazy, I have spent days in getting this working with windows 10 and wsl2, without success. If anyone can help it would be appreciated.

For me, network devices are visible if they’re on the same network (devcontainer running on Windows 11 with WSL).

One complication was, that I run my IoT devices on a separate closed-off VLAN and Windows 11 doesn’t seem to be able to easily deal with VLANs. I solved that by hooking up the machine on my home LAN but connecting WiFi to the IoT LAN so that the machine ends up in both networks.

I didn’t have to adjust anything in the default devcontainer docker setup. It just worked out of the box.

What doesn’t work is zeroconf autodiscovery or DHCP autodiscovery. I have no idea why and reading other posts I don’t seem to be the only one with that problem.

1 Like

Thank you for your reply @kongo09. No chance on my Win10 Desktop, don’t know why. I will retry it today with a Windows 11 laptop…

  • Do you have Win11 Pro?
  • Did you use WSL2 or WSL?
  • Did you chance any settings in the “Docker for Windows” application? What about the IP address?

Best regards



No settings changes

THANK YOU @kongo09, Windows 11 did the trick!

Update: I did a fresh setup on my Windows 10 PC, and now it is also working! Strange, but I think I was confused at the very beginning with autodiscovery not working. As I did not see any devices auto discovered, I started to change everything…

Im trying to do this with the boilerplate demo and it doesnt work:

It just tells me it can’t connect when I add it to the array…

I just came across a new challenge. While I could ping the devices from inside the devcontainer, I could not broadcast to them, which I need for device discovery.

I’ve now followed the advice from above and included --network=host with the runArgs and rebuilt the container. But that doesn’t bring the container onto the same 192.168.0.x network as the host, so the broadcast doesn’t work.

Now what?

from reading all sorts of docs, it seem that docker can bridge into the host network on Windows, but that’s different from “being” on the host network, so broadcasts don’t work. I’ve not been able to find any solution. --network=host does not work on Windows.