12 ms·
LXD containers on macOS at near-native speeds
- miohtama 4y agoThis 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.
- hannibalhorn 4y agoI'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.
- mark_l_watson 4y agoI am also happy with Lima on my M1 Macs. I wanted a Intel Linux container to run picolisp and it was easy to set up and works nicely.
- emptysongglass 4y agoCheck 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-open-source-client-for-container-development/ https://aws.amazon.com/blogs/opensource/introducing-finch-an...
- gpanders 4y agoLast I checked (which was not that long ago), Lima was stuck using 9p because QEMU for Darwin didn’t yet support virtiofs. Has this changed? Or maybe I’m just misremembering the details… EDIT: Looks like this was indeed just added in the last couple of weeks https://github.com/lima-vm/lima/commit/c18ae239b69a47db77436765b9b4861aaa0d595d https://github.com/lima-vm/lima/commit/c18ae239b69a47db77436...
- deleted 4y ago[deleted]
- JacobSeated 4y agovirtiofs is supported by newer Docker builds. It used to be very buggy with permissions, but the latest builds should have solved that. I am personally slowly moving back to Docker after having used limactl for a long time. It's just a pain in the ass. A Linux laptop is better for all intents and purposes, except the shitty battery life...
- est 4y ago> Prerequisites Install QEMU So in other words, qemu runs at near-native speeds?
- zweifuss 4y agoNot right now. Can be an order of magnitude slower compared to native. Depends a lot on the program and current task. Also, the QEMU defaults are not optimal.
- st3fan 4y agoYes, on recent MacOS it is mostly just an abstraction on top of the native Virtualization Framework.
- ricardobeat 4y agoNot if you’re running x86 emulation on an ARM host. It’s terribly slow. EDIT: This is from experience. When I started using a M1 mac, our docker builds on x86 images took up to 5x or 10x longer vs running on an arm64 image. Had slightly faster, but similar results running my own docker host on Lima, or podman, or building without docker inside a UTM host which also uses qemu.
- runeks 4y agoNo, it's decent performance. Minimum 25% of native, and even more using Rosetta: https://news.ycombinator.com/item?id=32149080 https://news.ycombinator.com/item?id=32149080
- ricardobeat 4y agoFor real world use cases like making cross-platform builds, 1/4 of native speed is pretty far from decent.
- jbverschoor 4y agoI don’t think that’s true. https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta https://developer.apple.com/documentation/virtualization/run...
- ryanmccullagh 4y agoDoes QEMU emulate the CPU on macOS?
- zweifuss 4y agoDepends. 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.
- eurasiantiger 4y agoCan confirm this works, but some applications will be slow. Seen a magnitude of difference with x86 JVM containers between Rosetta 2 and native ARM64.
- sirwhinesalot 4y agoRosetta 2 works great for AoT stuff but for JIT you'll always end up with at least a 2x slowdown since it needs to always JIT the JVMs JIT output. That said, it working at all is pretty amazing.
- saagarjha 4y agoThis doesn’t mean there’s a 2x slowdown. (I’ve seen 1.5x to 5x.)
- gizmo 4y agoThe CPU architecture of the VM and Host have to match, otherwise you get software emulation which is very very slow. It's good enough for occasional usage, but nowhere near good enough for daily development purposes.
- amelius 4y agoI 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_enterprise_linux/6/html/resource_management_guide/sec-relationships_between_subsystems_hierarchies_control_groups_and_tasks 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.
- mekster 4y agolxd is so much easier than alternatives like systemd-nspawn. 3 minutes search reveals an easy to follow tutorial. https://ubuntu.com/server/docs/containers-lxd https://ubuntu.com/server/docs/containers-lxd
- amelius 4y agoThanks but I wasn't talking about lxd, but about the underlying technology.
- deleted 4y ago[deleted]
- Izkata 4y ago> underlying technology I'm guessing bocker would be more useful for that: https://news.ycombinator.com/item?id=33218094 https://news.ycombinator.com/item?id=33218094
- e12e 4y agoYour initial comment mentions experimentation with lxd - did you mean experiment with lxc? The level of abstraction is very different (this is the raison-d'être for lxd, after all!). Lxc is somewhat to lxd as jails are to ezjails...
- yrro 4y agoThat'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_enterprise_linux/9/html/monitoring_and_managing_system_status_and_performance/setting-limits-for-applications_monitoring-and-managing-system-status-and-performance 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...
- st3fan 4y agoThis is part of the bigger Macpine project, which to me is much more interesting than LXD: https://github.com/beringresearch/macpine 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 """
- _cenw 4y agoIt feels like lima and colima are much more mature. Being unable to remap the SSH port (or other ports) alone makes this a non-starter.
- VWWHFSfQ 4y agoI ended up just getting a System 76 Meerkat computer for doing anything locally with LXC/Docker. Linux emulation in Windows or macOS is unbearably bad if you really need to do serious work.
- LoganDark 4y agoEven systemd will run in Docker on macOS. Can you clarify what makes macOS unacceptable for emulating Linux?
- cmeacham98 4y agoUsing a VM for Docker gives you the worst of both worlds. You get all the downsides of a VM (persistent wasted RAM/disk space, awful disk IO performance, etc) AND all the downsides of containers (difficult to introspect when your minimal image has no shell, janky networking, etc). On recent M1/M2 Macs you take the additional pain (and thus performance hit) of translation to x86 (because that's almost certainly what your containers are in.
- inkyoto 4y ago
- kaku1019 4y agoDoes QEMU emulate the CPU on macOS?
- 0x457 4y agoNo, Rosetta for Linux is used for that.
- loloquwowndueo 4y agoKeep 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.
- mistrial9 4y agothis is so .. exciting! .. however please recall that you the user are now using hardware that is remotely run in most cases by the OS vendor (and who-knows-what-else), with opaque code executing at multiple layers.
- remram 4y agoRemotely?
- barefeg 4y agoI like the progress that is being made for running containerized workloads on macOS. In my case I like some of the benefits of running the workload on a remote machine; such as no fan noise, less heat, less power consumption (especially on laptops). However the downsides can be also quite annoying, such as file sync times or IDE input lag. My current setup is to have both data and workload run on a remote machine and I connect to it via SSH. I can either run neovim inside or use the remote development plugin from VSCode. But as mentioned, the input lag can be very annoying. I’m wondering if there’s another setup where I can still retain some of the upsides of running the workloads remotely and still having a decent user experience (reduced lag)
- robertlagrant 4y agoIf you're on Kubernetes remotely, Telepresence [0] might be worth a look. [0] https://www.telepresence.io https://www.telepresence.io
- ytjohn 4y agoI was going to recommend DevSpace for kubernetes, looks like Telepresence has a lot of similar capabilities. I'll have to check that out as well. https://www.devspace.sh/ https://www.devspace.sh/
- iamveen 4y agoMutagen is what you're looking for! - Local and remote copy of files - Two way sync I've been using this for years, editing locally with Sublime, while running everything on a remote Linux vm. Because it's two way sync, anything created/modified on the server is also sync'd back to your local filesystem. I end up syncing most of the remote $HOME so I can easily fire up a new VM, sync, and go. It really is fantastic. https://mutagen.io/documentation/synchronization https://mutagen.io/documentation/synchronization
- seabrookmx 4y agoI've never noticed any input lag with VSCode remote SSH. I was under the impression the editor cached file contents (pulled entire files at a time over SSH) to resolve this issue. Or are you just talking about when using neovim?
- jsjohnst 4y agoThis 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?
- nerdponx 4y agoIt'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.
- pxc 4y agoAt first, I thought this was based on a syscall compatibility layer like Solaris' Linux Zones or WSL1 (RIP), or the Linux support in FreeBSD and NetBSD. If you've ever tried to spin up a whole bunch of Docker containers in WSL2 and watched `vmmem` memory and CPU usage explode, you know that 'near-native speed' in VMs comes with lots of asterisks. Does macOS have usable native macOS containers yet?
- saagarjha 4y agoNo.
- dchuk 4y agoSo 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.
- pbowyer 4y agoHave 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).
- charrondev 4y agoI 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.
- irusensei 4y agoCanonical has a product of their own: https://multipass.run/ https://multipass.run/ They all use the underlying OS hypervisor so I’m not sure you can get perceivable performance out of one solution over the other.
- alexklarjr 4y agoIDK what lightweight about virtualisation that takes at least 30% of cpu performance for context switching. And much more on io.
- riffic 4y agowould be nice to have macOS / Darwin kernel-native containers though.
- jbverschoor 4y agoToo bad almost all containers rely on bridged networking and different ports. Why not just bind to 127.0.x.y, where x is the project number, and y is the machine number. That way, you can just use default ports
- deleted 4y ago[deleted]
- Eleison23 4y agoBecause the loopback address doesn't work like that. 127.0.0.0/8 is defined as all loopback, which means the OS shouldn't differentiate between them, so any VMs binding on 127.* are going to interfere with the OS binding there.
- jbverschoor 4y agoAny other (local) range would be fine. 127.* does seem to have some strange behaviors
- ColCh 4y agoIt uses almost same mounting tech as colima (9p) Macpine: https://github.com/beringresearch/macpine/blob/71788e9c3c09cd11383885e4f8dd836ca34f0f8a/qemu/ops.go#L247 https://github.com/beringresearch/macpine/blob/71788e9c3c09c... colima: https://github.com/abiosoft/colima/blob/7ebcf14a69158afa43b23c4a5fd7c0b39122c1a2/embedded/defaults/colima.yaml#L97 https://github.com/abiosoft/colima/blob/7ebcf14a69158afa43b2... So it seems that it has same performance as colima project as well. As for IO performance, see this colima issue https://github.com/abiosoft/colima/issues/146#issuecomment-1025392658 https://github.com/abiosoft/colima/issues/146#issuecomment-1...
- myuzio 4y ago> Containers at near-native speeds Wow, I'm dying to see how it works! > brew install qemu :|