Live data from Hacker News

LXD containers on macOS at near-native speeds

beringresearch.github.io

51–60 of 134 posts

Re: LXD containers on macOS at near-native speeds

#51
post #40

So is there some canonical guide to running a docker compose style app on Mac m1 machines that has good filesystem performance? It seems like there’s many ways to approach the topic now so it’s hard to tell which one is “winning”. I’d love to containerize all of my local development efforts (scripts and rails apps) but the slow ass filesystem always ruined it in the past.

Because docker for Mac has always kind of sucked, I’ve moved on to making nix-based development environments and I’ve been very pleased so far. Lately I’ve been trying https://devenv.sh/ and it works great! I haven’t tried it for ruby, though I have used vanilla nix shell for ruby projects before and it worked quite well after I over-rode GEM_PATH and GEM_HOME to the correct values.

I've been using Colima lately and it's been a great experience. The only thing that didn't quite work was pushing an image to AWS ECR, but pulling images, building images (with BuildKit), and running containers all worked fine, and faster than Docker.

Re: LXD containers on macOS at near-native speeds

#52

This is cool and a worthwhile thing, but how is this different than the many (b/x)hyve clones and others based on QEMU that use MacOS’s virtualization framework to run a minimal Linux for containers? What’s the differentiator that makes this better (hopefully?) from what’s come before?

It's appealing to me because I can use LXD on both Mac and Linux now. One less discrepancy between those systems.

That said, there now seems to be a huge number of options for running various combinations of VMs and containers on Mac and Lenix now. I just use whatever seems popular and is easy to set up, but I have no sense of the pros and cons among them. I would love a coherent document on this topic.

Re: LXD containers on macOS at near-native speeds

#53
post #8
post #3

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

Yes, on recent MacOS it is mostly just an abstraction on top of the native Virtualization Framework.

Well, it can be. You can still emulate additional hardware with QEMU, and QEMU still has other backends (which it will use if you run a x86-64 OS on ARM macs).

Re: LXD containers on macOS at near-native speeds

#55
post #8
post #3

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

Yes, on recent MacOS it is mostly just an abstraction on top of the native Virtualization Framework.

It's not abstraction, QEMU uses Hypervisor framework (which is equivalent to KVM). Virtualization framework is Apple own hypervisor (which is equivalent to QEMU).

Re: LXD containers on macOS at near-native speeds

#56
post #42

Earlier quoted context omitted.

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

so arm macbooks are still problematic for developers who use containers and x86 servers... it's still surprising to me that they did this as i always got the sense that developer word of mouth helped drive a lot of macbook adoption in the 2000s.

In what way?

I use ARM containers locally to dev and test locally, check in the code and the build server creates an x86 image for deployment to the server.

Worst case you have to build the ARM container yourself locally and tag it with the "remote" name and docker will just use it instead of pulling the remote version.

Re: LXD containers on macOS at near-native speeds

#57

Earlier quoted context omitted.

Because docker for Mac has always kind of sucked, I’ve moved on to making nix-based development environments and I’ve been very pleased so far. Lately I’ve been trying https://devenv.sh/ and it works great! I haven’t tried it for ruby, though I have used vanilla nix shell for ruby projects before and it worked quite well after I over-rode GEM_PATH and GEM_HOME to the correct values.

I've been using Colima lately and it's been a great experience. The only thing that didn't quite work was pushing an image to AWS ECR, but pulling images, building images (with BuildKit), and running containers all worked fine, and faster than Docker.

I've tried Colima too but it has always felt sluggish compared to local dev. I don't think any form of cross-host filesystem sharing could ever be fast enough.

Re: LXD containers on macOS at near-native speeds

#58
post #40

So is there some canonical guide to running a docker compose style app on Mac m1 machines that has good filesystem performance? It seems like there’s many ways to approach the topic now so it’s hard to tell which one is “winning”. I’d love to containerize all of my local development efforts (scripts and rails apps) but the slow ass filesystem always ruined it in the past.

Because docker for Mac has always kind of sucked, I’ve moved on to making nix-based development environments and I’ve been very pleased so far. Lately I’ve been trying https://devenv.sh/ and it works great! I haven’t tried it for ruby, though I have used vanilla nix shell for ruby projects before and it worked quite well after I over-rode GEM_PATH and GEM_HOME to the correct values.

I’ve been using Nix for a few years and really like the direction of devenv. I much prefer the Nix model over containers everywhere.

Re: LXD containers on macOS at near-native speeds

#59
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... )

I don't understand why one needs to emulate a virtual machine to run a container. Why do you need a kernel? Why emulate physical devices, interrupts and everything else? Why cannot one run a container as a protected mode application?

Re: LXD containers on macOS at near-native speeds

#60
post #41
post #40

So is there some canonical guide to running a docker compose style app on Mac m1 machines that has good filesystem performance? It seems like there’s many ways to approach the topic now so it’s hard to tell which one is “winning”. I’d love to containerize all of my local development efforts (scripts and rails apps) but the slow ass filesystem always ruined it in the past.

Have you tried enabling Virtiofs in Docker Desktop? On my M1 Mac that sorted the performance for me for large PHP apps, and I haven't experienced the permissions problems that some people have (there is a test build that appears to fix those out now).

I have an M1 Pro MacBook and I turned on the 2 experimental settings and that sorted my performance issues.

I think the new virtualization framework just came out of beta though so now it’s just VirtuoFS that needs to be enabled.

Post reply on HN