4 ms·
My great confusion is why docker —-platform linux/amd64 is so much faster (almost native performance) than x86 UTM VMs. Can docker somehow leverage Rosetta?
by WanderPanda 3y ago
My great confusion is why docker —-platform linux/amd64 is so much faster (almost native performance) than x86 UTM VMs. Can docker somehow leverage Rosetta?
- koenigdavidmj 3y agoDocker runs an ARM kernel and uses qemu in user mode on the individual binary level. Anything CPU-bound is emulated, but as soon as you do a system call, you’re back in native land, so I/O bound stuff should run decently.
- jbverschoor 3y agoDitch Docket.. Orbstack is fast..
- steeve 3y agoIt does yes, Apple provides Rosetta for Linux: https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta https://developer.apple.com/documentation/virtualization/run...
- cpuguy83 3y agoYes, Docker can leverage Rosetta. I haven't used Docker Desktop in a bit (b/c I end up doing my work in a VM on Azure since I work on Azure), but not too long ago there was an option to enable it in the settings panel, not sure if it's default or not these days. Any Linux VM can use Rosetta[1] you just need to enable it when booting the vm. This creates a shared directory in the vm that you need to mount and then register Rosetta with binfmt_misc (same way Docker uses qemu). [1] https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta https://developer.apple.com/documentation/virtualization/run...
- MBCook 3y agoI remember seeing it was out of beta in the release notes of Docker Desktop not too long ago.
- lloeki 3y ago> Any Linux VM hosted under Virtualization.framework can use Apple's Rosetta 2 for Linux translation binary via binfmt_misc FTFY You don't need the mount, it just exposes the Linux binary stored on macOS, which you can copy over. The binary does check for it being run under virt.fw, although some folks managed to hack that away (IIRC running it on AWS whatever)
- arianvanp 3y agoNote that UTM also supports rosetta. Boot up an aarch64 image with Rosetta support and then load the mounted binfmt handler. Now you can run x86 binaries on your aarch64 UTM VM. Works flawlessly. If you use NixOS you can simply enable https://search.nixos.org/options?channel=23.11&show=virtualisation.rosetta.enable&from=0&size=50&sort=relevance&type=packages&query=rosetta https://search.nixos.org/options?channel=23.11&show=virtuali...
- naikrovek 3y agoMacOS on Apple Silicon does not allow whole VM Rosetta. You must run arm64 MacOS or Linux VMs and those VMs can run x86_64 binaries via Rosetta. Apple documented this. Running an x86_64 virtual machine on MacOS requires software emulation, which is why it is so slow. Docker sets it up correctly so that the Linux VM it uses is arm64 but the binaries in the containers are x86_64, so that Rosetta can be used on those binaries.