chipmk / docker-mac-net-connect

Connect directly to Docker-for-Mac containers via IP address 🐳 💻
MIT License
402 stars 41 forks source link

Could not add link chip0: operation not supported #10

Closed bloatfan closed 2 years ago

bloatfan commented 2 years ago

hi, my linux vm setup get in trouble

some log

DEBUG: (utun5) 2022/06/03 01:59:00 Setting up Wireguard on Docker Desktop VM
Creating WireGuard interface chip0
Could not add link chip0: operation not supported
Assigning IP to WireGuard interface
Configuring WireGuard device
Failed to configure wireguard device: file does not exist
Setup container complete

https://github.com/chipmk/docker-mac-net-connect/blob/59f4bdb597df6e493cf3ccfc21eecedc548467ab/client/main.go#L86

image

software info

OS: Monterey 12.3.1
Docker Desktop 3.3.3

Can you take a look? Looking forward to your reply,thanks

gregnr commented 2 years ago

Hey @lslz627, thank you for reaching out. I was able to reproduce your issue by installing Docker Desktop 3.3.3.

After going through each Docker Desktop version one-by-one, I've finally determined that the issue is related to the Linux kernel version. Docker Desktop 3.3.0 - 3.5.2 uses kernel version 5.10.25-linuxkit which doesn't appear to load the WireGuard kernel module by default (WireGuard is required for docker-mac-net-connect). Tested using:

$ ip link add dev wg0 type wireguard
RTNETLINK answers: Operation not supported

I wasn't able to manually load it either:

$ modprobe wireguard
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.10.25-linuxkit/modules.dep.bin'
modprobe: FATAL: Module wireguard not found in directory /lib/modules/5.10.25-linuxkit

The issue is fixed in Docker Desktop 3.6.0+ which uses kernel version 5.10.47-linuxkit:

$ ip link add dev wg0 type wireguard
$ ip a
...
9: wg0: <POINTOPOINT,NOARP> mtu 1420 qdisc noop state DOWN group default qlen 1000
    link/none

Is there any reason you are using an older version of Docker Desktop? Upgrading to at least 3.6.0 should solve your problem.

I did a deep dive into linuxkit commit history to try to determine what exactly changed between 5.10.25 and 5.10.47, but unfortunately it wasn't clear when this actually happened (first appearance of 5.10.x was already at 5.10.34). Perhaps Docker Desktop used a forked version of linuxkit (you can see they publish their docker/for-desktop-kernel separately from linuxkit/kernel), which unfortunately they don't provide the source code for.

Let me know if this helps you move forward or if you have any other questions.

bloatfan commented 2 years ago

@gregnr Thank you for taking the time to look at my problems,I have upgrade my docker to latest version ( 4.8.2 ) by your remaining and now it's ok

Thanks for your information and for being so helpful, Really appreciate 👍