Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows containers have no internet access, but Linux containers do - with VPN-Client active on host

I have a Stonesoft VPN-Client and Docker-for-Windows installed on my host machine. My Windows containers seem to fail to resolve any host (even www.google.com). My Linux containers however work perfectly fine. When I disable the VPN Adapter in my network adapter list, the windows containers can access the internet again. But I need them to work with VPN active.

So I researched for quite a while and tried to following:

  1. Check the adapter priorities in powershell: Get-NetIPInterface -AddressFamily IPv4 | Sort-Object -Property InterfaceMetric -Descending

enter image description here

It was said, that the primary adapter should have the lowest metric value. Which is ethernet in my case and that seems fine. https://github.com/docker/for-win/issues/2760

  1. Run image with --dns=8.8.8.8 flag. Did not solve the issue.
  2. I went into the Virtual-Switch settings of the Hyper-V Manager. I set the switch called 'nat' to 'external network'. Well my containers got internet connection after that. But it automaticly disabled the VPN adapter so that's not right.

  3. Setting the IPv4 address and DNS of the vEthernet(nat) to automatic. Also did not help.

  4. Reinstalling Container Tools, Hyper-V and Docker. No success.

  5. Trying older versions of Docker-for-Windows. No success.

Here is some information about my environment:

My network adapters:

enter image description here

My Docker settings are default.

enter image description here

enter image description here

Hyper-V virtual switches:

enter image description here

vEthernet(nat) IPv4 settings:

enter image description here

vEthernet(DockerNAT) IPv4 settings:

enter image description here

vEthernet(Default Switch) IPv4 settings:

enter image description here

ipconfig /all on my host:

enter image description here enter image description here

I hope this helps and someone can answer this question. It has been bothering me for quite a while now.

EDIT:

Since there was no actual question in there:

How do I solve this problem?

like image 472
Moritz Rinow Avatar asked Oct 27 '22 13:10

Moritz Rinow


1 Answers

I just figured this out:

1). Follow: https://docs.docker.com/machine/drivers/hyper-v/#example:

2). Start hyper v (may need to enable): https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v

3). Then in hyper v create external virtual switch. Select your wifi adapter. (should work with vpn on or off).

4). reboot.

5). Start container and attach to new network.

docker network ls
docker network connect "John Windows Container Switch" win1809
docker network inspect "John Windows Container Switch"

shows:

        "Containers": {
            "b8c4ae07761fdf082602f836654013b8d83a717cce9156880a80c7542d855842": {
                "Name": "win1809",
                "EndpointID": "e84652fc93fd1fa2970c3bdcad513d8928fc35823a9f8cf0e638926b6091a60c",
                "MacAddress": "00:15:5d:fb:77:dd",
                "IPv4Address": "",
                "IPv6Address": ""

6). docker exec -it win1809 powershell

ping www.google.com

Pinging www.google.com [172.217.10.36] with 32 bytes of data:
Reply from 172.217.10.36: bytes=32 time=19ms TTL=118
Reply from 172.217.10.36: bytes=32 time=18ms TTL=118
Reply from 172.217.10.36: bytes=32 time=18ms TTL=118
Reply from 172.217.10.36: bytes=32 time=14ms TTL=118
like image 56
Kierk Avatar answered Nov 26 '22 15:11

Kierk