Docker for Windows on Windows Server 2022: Connecting to Two Different Network Interfaces

28 Views Asked by At

I am using Docker for Windows on Windows Server 2022. My Docker server has two network interfaces connected to two different VLANs. Each Docker container needs to connect to both VLANs - one hosts a database and the other hosts a TCP/IP endpoint. Each Docker container also needs to use DHCP to get a dynamic IP address from the corresponding VLAN.

Here’s what I’ve done so far:

Created two transparent Docker networks using the following commands:

docker network create -d transparent --subnet 10.1.12.0/24 --gateway 10.1.12.1 -o com.docker.network.windowsshim.dnsservers="172.1.2.1,172.1.2.2" transparent_localLan
docker network create -d transparent --subnet 10.2.100.0/24 --gateway 10.2.100.1 -o com.docker.network.windowsshim.dnsservers="172.16.2.1,172.16.2.2" transparent_vLan499

Created a Docker container and added both networks using these commands:

docker create --isolation=hyperv -it --name testnetwork mcr.microsoft.com/windows/nanoserver:ltsc2022 
docker network connect transparent_localLan testnetwork
docker network connect transparent_vLan499 testnetwork
docker network disconnect nat testnetwork

Started the container and attached to it.

The expected behavior was that DHCP would work and that I could ping both gateways (ICMP is active on the gateway). However, while DHCP worked, I could not ping the gateway. I also installed my application, but neither the database on “localLan” nor the external TCP/IP endpoint was reachable.

0

There are 0 best solutions below