Uh oh!
There was an error while loading. Please reload this page.
Add file handle attachment support - #759
Conversation
nirs
commented
Jun 1, 2026
@curdbecker sounds like cool feature! but with VZFileHandleNetworkDeviceAttachment it will not be easy to configure port forwarding and other options that are much easier with the native vmnet support introduced in macOS 26. |
@nirs thanks a lot :) Yes, the native bridging support is likely the go-to-alternative in any case, but if you maybe want to take a look at the linked PR in container from torarnv and the discussion as well as mine, then unfortunately the entitlement blocks using the integrated bridging support as far as I understand. I also took a look at your new project and it seems to be missing there as well, right? Without the entitlement one can only choose between SIP and bridging. Then I would always choose SIP in a heartbeat. The goal here from me is also that I do not want to have classical container features like port forwarding etc., but I would like to have containers where I do have a great deal of control about the underlying VM, e.g. kernel, init ad command line, as well as still benefiting from everything great the container eco system has brought us. The worse performance (although you seem to have put a great deal of work into optimization - that is something that would be as well also possible here) and the overhead of having a bridge would be okay for me when I need it :) Btw, I used your vmnet-helper with this little tool when creating a drop-in of Docker Desktop's VM runner to achieve the goals above... That's how I learned of it. Very nice! :) |
5a17d4a to
ca0d56cComparecurdbecker
commented
Jun 15, 2026
Updated to latest |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Thanks for the changes. Ping me when done and we can get this PR in |
nirs
commented
Jun 23, 2026
|
curdbecker
commented
Jun 23, 2026
@nirs Yes, vmnet works, but as @torarnv pointed out bridging still apparently still requires the entitlement. He also had to disable SIP in order to make that work. And from what I have seen in general asking for a custom NIC mac address doesn't work as well. Then the API call fails. I think this is likely connected to the bridging restriction. Or am I wrong here? That would surprise me quite a lot 😱 |
ca0d56c to
fb4f40aComparecurdbecker
commented
Jun 23, 2026
@crosbymichael Thanks for the review. Really excited that we can get this in, since especially the DHCP PNP part from tornav is quite interesting. Let me know if I should have missed anything (my ADHD self can't always too certain even after triple checking things...) :) |
fb4f40a to
8b121acComparetorarnv
commented
Jun 23, 2026
@crosbymichael Have you had a look at the original PR in apple/container#1463 and the discussion there with @dcantah and @jglogan? I don't mind exactly which PR gets merged if it brings bridge-mode to Are we targeting the What are the tradeoffs between the two when it comes to:
For the But if we can have both, where |
@torarnv Thanks for getting it started. It helped me quite a lot so far in most of my use cases. I actually run docker solely in container now and with bridging, separate docker daemons etc. basically all my issues are solved :) That's why I also just put the changes on top of your PR and now rebased them. Didn't make sense to open too many several independent PRs here - and it would also have confused me quite a bit locally... That being said: I actually do not see an "either or" here - both of them make sense from my point of view - even independently. Especially in the context of For instance, one of the things I am also using it for is emulating an entire network environment for testing. And it is quite helpful that the environment then is fully configurable inside a single process and also remains completely transparent to the outer OS networking infrastructure. Then things don't get as messy as before with explicit VM networking, container namespaces etc. What I haven't done yet, but peaked my interested while I was looking into the whole Docker networking mess was also something like ns-3. The way I understand it, file handle support would allow also to plug it directly in there... and then replace the hack-ish solutions that I had before. (Although colleagues warned me that it can also simulate arbitrary networks and can therefore get quite complicated quite soon...) It would be also interesting to expose file handle networking as an option directly in container. The whole dedicated bridging to get around the entitlement is although another topic anyways... 😂 |
torarnv
commented
Jun 23, 2026
@curdbecker Thanks for the detailed summary I'd be happy if we can have both, so thumbs up from me on this PR 👍🏻 |
nirs
commented
Jun 23, 2026
The VZ bridged device attachment requires root or Example run in bridged mode: % build/vmnet-run --operation-mode bridged --shared-interface en10 -- sleep 1 INFO [runner] running on macOS 26.5.1INFO [main] running build/vmnet-helper v0.12.0-5-g29ce071 on macOS 26.5.1INFO [main] running as uid: 501 gid: 20INFO [main] using bulk_forwarding: true{"vmnet_write_max_packets":256,"vmnet_read_max_packets":256,"vmnet_mtu":1500,"vmnet_interface_id":"4FE2BC19-4803-48CA-B4E7-7A01EF6DEF41","vmnet_max_packet_size":1514,"vmnet_mac_address":"d6:f7:f4:ba:ec:95"}INFO [main] started vmnet interfaceINFO [main] started host forwardingINFO [main] started vm forwardingINFO [main] waiting for terminationINFO [main] received signal Terminated: 15INFO [main] stopped vmnet interface
I would not disable SIP, this is your safety net.
I had no issues using the mac address returned from vmnet or using my own generated MAC address: Tested with vfkit, krunkit, and qemu.
Not very clear what you tried and what failed |
To clarify, a properly signed |
nirs
commented
Jun 23, 2026
Interesting - what do you mean by properly singed? Can this work for vfkit? |
curdbecker
commented
Jun 23, 2026
@nirs - sorry, but it seems that we are talking past each other. That fact is really out of the question. This statement was meant in regard to the BridgedNetworkInterface that also ended up in this PR, since it is quite hard to have them separated when building/developing the related PR in container. This one still requires the entitlement as tornav pointed out here :) And for me running in bridge mode without the OS-level bridging support and a container-integrated version of
Yes, of course, sorry - like I said this was not in any way meant a suggestion. In doubt also take a look at the related discussion. Nobody should ever run in production without SIP for basically any reason in my opinion :)
Well, sorry, I have to look it up again, since I am in quite a lot of different topics now, but I basically had accepted it. I think it was |
@tornav Thanks a lot :) Yes, I would also glad to have both - even without the overhead of "manual bridging". Then I would also opt to your implementation directly, since it is certainly way more efficient and straightforward. It would be awesome if maybe someone here from the amazing Apple folks that created these projects could maybe "lobby" for a way to get around the requirement of an explicit signature for this entitlement from Apple. I would be amazing if we could this also using normal development signing as for most other entitlements. |
torarnv
commented
Jun 23, 2026
I mean that the binary is signed with the https://github.com/openai/tart is an example of a product that does that.
As long as the project ( Which is why having |
curdbecker
commented
Jun 23, 2026
I also just looked up the again the relevant apple documentation, see here. It does not tell you thought that you can't just self-sign this entitlement or use a "normal" developer certificate. Thankfully tornav discovered that before I have, since I would likely have been quite frustrated 😂 😂 |
nirs
commented
Jun 23, 2026
Apple approval is not an acceptable solution for an open source project. |
torarnv
commented
Jun 23, 2026
I'll leave you to make that choice for For https://github.com/apple/containerization and https://github.com/apple/container I see no reason why the official releases can't be built with a signing identity that is given this entitlement by the very entity that manages the project. |
8b121ac to
d0ce69cComparecurdbecker
commented
Jun 24, 2026
Well, of course I forgot to re-execute the tests locally yesterday evening, so the rebase actually was clean, but another non-optional use of the IPv4 address sneaked in there. Just fixed that and all tests pass for me locally now :) |
Rjvs
commented
Aug 8, 2026
@curdbecker just noting the PR still has the changes requested tag, which might be why @crosbymichael hasn't re-reviewed it despite your request... is it worth addressing that last change request some other way, so this PR doesn't just languish? |
curdbecker
commented
Aug 8, 2026
@Rjvs Thanks for the hint... Yeah, I do not know. I already pressed the re-request review button. Now I did it again, but the requested change does not disappear? And I am either ADHD-blind right now or there are really no further changes in the diff anymore and this is really a Github bug? Do you see anything? I thought actually the heated discussion that ensued here last time was what made the pull request a bit less interesting? |
curdbecker
commented
Aug 8, 2026
Adds BridgedNetworkInterface, which uses VZBridgedNetworkDeviceAttachment to place a container on the host's physical network. The IP address is assigned by the upstream DHCP server rather than our allocation pool, so ipv4Address is always nil for this type. Makes Interface.ipv4Address optional (CIDRv4?) to accommodate interfaces whose address is not known at configuration time. Updates all existing conformers (NATInterface, NATNetworkInterface, VmnetNetwork.Interface) and guards the static address/route setup in VirtualMachineAgent+Interface behind an ipv4Address nil-check. Fixesapple#457 Co-authored-by: Curd Becker <me@curd-becker.de>
When configureDns is called with an empty nameservers list or no domain, read /proc/net/pnp (written by the kernel IP_PNP DHCP client) and use any nameserver and domain lines found there. The two are filled in independently, so an explicit nameserver does not prevent the domain from being read from pnp. This provides automatic DNS configuration for bridge-mode containers without a new RPC or proto change. Co-authored-by: Curd Becker <me@curd-becker.de>
FileHandleNetworkInterface uses VZFileHandleNetworkDeviceAttachment to attach the container to a file handle where another service can provide an arbitrary network. This might be an entirely simulated network, a virtual network like a VPN, e.g. using Wireguard, but it could be also a bridged physical network from the host where the service will then take over the responsibility of bridging the traffic between the container and host. We do not make any assumption about IP addresses for now, but instead also assume that the IP address can get assigned via DHCP.
d0ce69c to
3062d54Comparecurdbecker
commented
Aug 8, 2026
@crosbymichael Ok, rebased to the current master again. And adapted to your changes in Maybe we can now talk about what's going on here again? It's a bit annoying to keep adding |

Based on @torarnv's existing PR this PR adds also exposes a
VZFileHandleNetworkDeviceAttachmentvia aFileHandleNetworkInterfaceto allow connection a container to an arbitrary file handle provided by another service.This attachment is used by tools like nirs/vmnet-helper to bridge the container to an existing host interface. It opens also up the possibility to add a similar service directly into container to circumvent the need for without having the binary signed with the
com.apple.vm.networkingentitlement, e.g. during container development.