Live data from Hacker News

LXD containers on macOS at near-native speeds

beringresearch.github.io

11–20 of 134 posts

Re: LXD containers on macOS at near-native speeds

#11
This is part of the bigger Macpine project, which to me is much more interesting than LXD: https://github.com/beringresearch/macpine

""" The goal of this project is to enable MacOS users to:

Easily spin up and manage lightweight Alpine Linux environments. Use tiny VMs to take advantage of containerisation technologies, including LXD and Docker. Build and test software on x86_64 and aarch64 systems """

Re: LXD containers on macOS at near-native speeds

#12
post #6

I experimented with LXD containers on Linux recently, but I found the technology it builds on (cgroups) too hard to wrap my head around, and tutorials leave me in the dark. E.g. here is page 2 of one tutorial: https://access.redhat.com/documentation/en-us/red_hat_enterp... All these rules made no sense to me, and while I suppose they become clear at some point, I like my tutorials to be clear from the start.

That's documentation for RHEL 6 which is now 12 years old. It pertains to cgroups v1 which was horribly complex. It was replaced by cgroups v2 which is much simpler; there's now a single hierarchy of cgroups.

https://access.redhat.com/documentation/en-us/red_hat_enterp...

That said I don't remember having to learn all that much about cgroups when I last looked at lxc...

Re: LXD containers on macOS at near-native speeds

#14
post #3

> Prerequisites Install QEMU So in other words, qemu runs at near-native speeds?

QEMU can use the MacOS virtualization framework layer to run a VM built for the same arch without going through any translation. From there you can register Rosetta as a runtime and use it to run x86-64 Linux apps on ARM64 if you want. ( https://developer.apple.com/documentation/virtualization/run... )

Wait, what? QEMU can pass x86 instructions directly to Rosetta without emulating an entire host OS?

Re: LXD containers on macOS at near-native speeds

#15

Earlier quoted context omitted.

QEMU can use the MacOS virtualization framework layer to run a VM built for the same arch without going through any translation. From there you can register Rosetta as a runtime and use it to run x86-64 Linux apps on ARM64 if you want. ( https://developer.apple.com/documentation/virtualization/run... )

Wait, what? QEMU can pass x86 instructions directly to Rosetta without emulating an entire host OS?

It does emulate the OS (it’s the point of running stuff in qemu ) but doesn’t translate the instructions

Re: LXD containers on macOS at near-native speeds

#16

Earlier quoted context omitted.

QEMU can use the MacOS virtualization framework layer to run a VM built for the same arch without going through any translation. From there you can register Rosetta as a runtime and use it to run x86-64 Linux apps on ARM64 if you want. ( https://developer.apple.com/documentation/virtualization/run... )

Wait, what? QEMU can pass x86 instructions directly to Rosetta without emulating an entire host OS?

No, QEMU runs an ARM VM. Inside that VM, Rosetta for Linux can be used to run x86 executables, just like on macOS.

Re: LXD containers on macOS at near-native speeds

#17
post #2

This is good news. I come from the development background and the number one use case of containers on macOS is development enviroments, as on Windows too. For this use case, file system IO has always been bottleneck, not CPU. I do not know if there is some silver bullet in the horizon that could make this faster.

I've been really impressed with what I can accomplish with lima-vm, beyond just "replace docker desktop". The latest pre-release supports Virtualization.framework, including virtiofs.

Check out Finch, a new OSS project out of AWS that packs OSS container tools like Lima and nerdctl together: https://aws.amazon.com/blogs/opensource/introducing-finch-an...

Re: LXD containers on macOS at near-native speeds

#18

Does QEMU emulate the CPU on macOS?

Depends. QEMU can use Apple's Hypervisor virtualization framework to run ARM64 operating systems on Apple Silicon without emulation. It seems to be possible to then use Rosetta 2 to run x64-code on those operating systems.

Re: LXD containers on macOS at near-native speeds

#20
Keep in mind lxd can manage two types of “containers” these days - the traditional cgroup-based kind that runs as its own set of processes on top of the hosts kernel with isolation, and traditional qemu-backed virtual machines. The user experience is homogeneous but the backing engines are different as noted here.
Post reply on HN