I am trying to access Kafka installed on WSL from a docker container running on the same Windows 11 Pro box.
I can successfully access the WSL from the host Windows but the network interface visible inside the docker container reports the target IP as unreachable.
So, the setup in more details:
Windows Pro:
ipconfig
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::81b0:aa6c:3acb:52fb%7
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Wireless LAN adapter Local Area Connection* 1:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : dhcp.ucom.am
Link-local IPv6 Address . . . . . : fe80::40d7:4b84:b264:183f%19
IPv4 Address. . . . . . . . . . . : 192.168.1.109
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter vEthernet (Default Switch):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::17f5:3dc0:93a3:7e6d%30
IPv4 Address. . . . . . . . . . . : 172.19.112.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
Ethernet adapter vEthernet (WSL (Hyper-V firewall)):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::a5b4:8ccc:77a7:8c75%48
IPv4 Address. . . . . . . . . . . : 172.27.80.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
The interface in question’s IP 172.27.80.1:
Docker Engine: v25.0.3
WSL Ubuntu Linux:
uname: Linux Utopia 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
ifconfig:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet **172.27.88.164** netmask 255.255.240.0 broadcast 172.27.95.255
inet6 fe80::215:5dff:feea:c915 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:ea:c9:15 txqueuelen 1000 (Ethernet)
RX packets 546948 bytes 728340481 (728.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 142803 bytes 10004297 (10.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 118326 bytes 20003490 (20.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 118326 bytes 20003490 (20.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Docker container:
uname: Linux docker-desktop 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 Linux
docker run: docker run --name=kafka --network=host -it python3.10.14-alpine3.19 sh
ifconfig
(cut out other irrelevant interfaces):
...
br-2b3932ab9cca Link encap:Ethernet HWaddr 02:42:94:44:16:A5
inet addr:172.27.0.1 Bcast:172.27.255.255 Mask:255.255.0.0
inet6 addr: fe80::42:94ff:fe44:16a5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:81 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:3786 (3.6 KiB)
...
eth0 Link encap:Ethernet HWaddr 22:7F:BA:C1:AE:F3
inet addr:192.168.65.3 Bcast:192.168.65.255 Mask:255.255.255.0
inet6 addr: fe80::207f:baff:fec1:aef3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1230322 errors:0 dropped:0 overruns:0 frame:0
TX packets:1183700 errors:0 dropped:102 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:117289185 (111.8 MiB) TX bytes:469511171 (447.7 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:113 errors:0 dropped:0 overruns:0 frame:0
TX packets:113 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10510 (10.2 KiB) TX bytes:10510 (10.2 KiB)
...
ip route
:
default via 192.168.65.1 dev eth0
127.0.0.0/8 dev lo scope host
172.17.0.0/16 dev docker0 scope link src 172.17.0.1
172.24.0.0/16 dev br-e19898417128 scope link src 172.24.0.1
172.25.0.0/16 dev br-69c5956ec8b4 scope link src 172.25.0.1
172.26.0.0/16 dev br-e492384c3d90 scope link src 172.26.0.1
172.27.0.0/16 dev br-2b3932ab9cca scope link src 172.27.0.1
192.168.49.0/24 dev br-5e9534f79c66 scope link src 192.168.49.1
192.168.65.0/24 dev eth0 scope link
192.168.65.1 dev eth0 scope link
192.168.65.7 dev services1 scope link
192.168.176.0/20 dev br-cc0f94b89d47 scope link src 192.168.176.1
192.168.192.0/20 dev br-f33839247be2 scope link src 192.168.192.1
I successfully connect to the WSL services from Windows host:
curl 172.27.88.164
<!DOCTYPE html>
<html>
...
ping 172.27.88.164
Pinging 172.27.88.164 with 32 bytes of data:
Reply from 172.27.88.164: bytes=32 time<1ms TTL=64
Reply from 172.27.88.164: bytes=32 time<1ms TTL=64
Reply from 172.27.88.164: bytes=32 time<1ms TTL=64
Reply from 172.27.88.164: bytes=32 time<1ms TTL=64
Anyhow, if a try to access the same IP address from within the docker container, I get this:
# traceroute 172.27.88.164
traceroute to 172.27.88.164 (172.27.88.164), 30 hops max, 46 byte packets
1 172.27.0.1 (172.27.0.1) 3140.671 ms **!H** 3111.142 ms **!H** 3119.825 ms **!H**
I tried to disable/enable the vEthernet (WSL (Hyper-V firewall)) internet adapter but nothing changes.
Emil M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.