How to get physical network device layer2 payload into Docker DevContainer?

Hello,

I have tested out some approaches to get my physical network device layer2 payload into Docker DevContainer. Goal would be to setup a small eth package processor within my linux docker env. I can work without docker, but i can’t change the setup (windows host, linux repo).

My setup:

  • Windows 11
  • Docker Desktop with WSL2 support
  • DevContainer running Ubuntu-22.04 LTS and linux repo code

What i’ve tried so far:

  1. I’ve tried configurate my WSL2 distro by setting networkMode to mirrored within .wslconfig. Found out that mirrored is not supported within Docker Desktop Windows. I also tried to use Docker CE within my WSL2 distro to get rid of docker-desktop limitations but this also didn’t work since this will allow my devContainer to see the WSL eth adapters, but Windows-WSL(Ubuntu) is still not working.

  2. I’ve tried setting DevContainer.json to --network=“Host”, which i verified that it was correctly set by inspecting my build image. But this also doesn’t give me access to my ETH Devices within my host windows network.

MacVLan apparently also doesnt work with a Windows Host. Now I’m out of options.

Can someone guide me into a new direction or correct my approaches?

Sadly this is not feasible.

networkMode=mirrored indeed does affect the docker desktop distribution itself. Though, the docker engine it runs as an isolated process is not able to see the mirrored interface.

You best bet would have been networkMode=mirrored with docker-ce. But apparently that’s not working either. This does not bridge the wsl2 distribution’s network into the hosts network. The incoming packages on either host/distribution side are just mirrored to the other side. From what I remember the network interfaces inside the distribution uses a different mac address than the host’s nic uses.

ipvlan and macvlan don’t work either.

It should work if you use docker-ce on a vm with a vnic attached to a vswitched bridged into your lan.