-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ergonomic creation of macvtap
devices inside containers
#45546
Comments
Huh? The kernel documentation says that a tun/tap device is created by opening Are you trying to "mount" an existing tap device on the host into the container? Use |
@corhere Maybe the problem is specific to Because if you create a
no corresponding My current code to workaround this is:
This works.. But as it requires the user to manually add the resulting cgroup number to the compose file, it is far from user-friendly. |
Could you not do something like this? services:
foo:
devices:
- "/dev/tap${TAP_NR}:/dev/my-vtap" $ TAP_NR=$(</sys/class/net/"${VTAP}"/ifindex) docker compose up |
I am not sure if I understand what you mean? I create the If they need to first create a |
Sorry, I misunderstood. I thought you wanted to project an existing macvtap device on the host side into a container, not create a vtap interface inside the container. |
Very relevant kernel discussion for exactly this sort of use-case. The patches were never merged. It does raise an interesting point, though: devices are not namespaced, so I'm not even sure how dockerd could be able to determine which container(s) to project a dynamically-created device node into in a generic way, so that it does not need specific knowledge about macvtap devices. If you are okay with the macvtap device bridging to an interface in the host network namespace, I think that creating the macvtap interfaces on the host side and mounting them into the container is the only other viable workaround. You could wrap the logic to set up the tap device and start the container up into a script to make it more user-friendly. |
I really want to avoid having to run any scripts on the host. I can dynamicly create |
macvtap
devices inside containers
Description
Currently, to create a TAP interface for use with
macvtap
is extremely complicated from inside a Docker container.Because to create the
/dev/tapX
file for the interface usingmknod
, you need to havedevice_cgroup_rules
permissions for the corresponding major/minor numbers. But these numbers can never be known in advance, so you cannot include them in the docker-compose file.The only workaround is let the container get these values, display them to the user via the logfile, and then let the user manually modify the containers
device_cgroup_rules
configuration with these values.It would be so much more user-friendly if a special permission could be added, like
NET_ADMIN
, that would allow the creation of TAP devices without having to specify any cgroup rules. Because they are different on each system.The text was updated successfully, but these errors were encountered: