Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?


Yes, 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/run...


> 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)


I remember seeing it was out of beta in the release notes of Docker Desktop not too long ago.


Docker 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.


Note 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=virtuali...


It does yes, Apple provides Rosetta for Linux: https://developer.apple.com/documentation/virtualization/run...


MacOS 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.


Ditch Docket.. Orbstack is fast..




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: