[HN Gopher] Lima: A nice way to run Linux VMs on Mac
       ___________________________________________________________________
        
       Lima: A nice way to run Linux VMs on Mac
        
       Author : jseliger
       Score  : 279 points
       Date   : 2023-07-10 16:44 UTC (6 hours ago)
        
 (HTM) web link (jvns.ca)
 (TXT) w3m dump (jvns.ca)
        
       | [deleted]
        
       | espe wrote:
       | lima is nice. just beware that os updates can accidentially nuke
       | the vm. got to try out utm sometime.
        
       | hank_z wrote:
       | Curious to know whether the Linux VMs on Apple Silicon Macs are
       | also based on arm or not.
        
         | asmor wrote:
         | Configurable. Also runs ARM on Intel Macs if you want.
        
       | eoinboylan wrote:
       | Oh this is very nice, I spent about 2 hours getting around some
       | bullshit bug with Vagrant and VirtualBox to work on ARM OSX at
       | the weekend. This took 5 minutes to setup.
        
       | vuln wrote:
       | Has anyone figured out a way to run VMs on the M series iPad
       | Pros?
        
         | fredoliveira wrote:
         | I believe UTM will let you do just that.
        
         | chazeon wrote:
         | Have you tried iSH[1]?
         | 
         | [1]: https://ish.app/
        
       | dabedee wrote:
       | I recommend having a look at Macpine [1] which allows you to run
       | lightweight alpine VMs on MacOS with easy port forwarding, file
       | sharing; you can also easily run docker inside of it and use
       | docker context to target it.
       | 
       | [1] https://github.com/beringresearch/macpine
        
       | markstos wrote:
       | Is it pronounced like Lima the bean (LEYE MA) or Lima the city in
       | Peru (LEE MA)?
        
         | blacksmith_tb wrote:
         | I was assuming it was lim-UH, for LInux+MAc?
        
       | golanggeek wrote:
       | Very nice. To have some sub directories as read-write would be
       | super useful.
        
         | adamgordonbell wrote:
         | It totally works with read-write enabled and in fact rancher
         | uses it this way. Make this change:                   mounts:
         | - location: "~/sandbox"           writable: true
         | 
         | Lima cautions against this:                     # Setting
         | `writable` to true is possible, but untested and dangerous.
         | 
         | But I never hit any problems when I played around with it. Here
         | are my notes: https://earthly.dev/blog/lima/
        
           | davidcollantes wrote:
           | Very helpful notes on your blog, thank you for sharing!
        
       | throw0101a wrote:
       | The post mentions Homebrew, but seems to also be available under
       | MacPorts:
       | 
       | * https://ports.macports.org/port/lima/
        
         | jonhohle wrote:
         | Nice to see MacPorts love!
        
       | lelanthran wrote:
       | What I'd really like is to run MacOS on Linux.
       | 
       | When I want to make sure my software works on MacOS, it'd be nice
       | if I could do that without having to have a whole other computer
       | sitting in front of me.
        
         | Aleklart wrote:
         | https://github.com/kholia/OSX-KVM
        
         | ant6n wrote:
         | What I like to do is get a Wondows VM on Mac. I couldn't get
         | Sketchip to work under Wine so actually installed Win10 again
         | (ugh).
        
           | pjmlp wrote:
           | Parallels would be an option.
        
       | jbverschoor wrote:
       | I'd just want the following:
       | 
       | In a cli, I want to start "vm"
       | 
       | It should check the current directly and go up each time similar
       | to.asdf or .rbenv, looking for a .virtconfig dir
       | 
       | Depending on the config, I want:
       | 
       | 1: it running a foreground instance, soo I don't need ssh, and I
       | know that it will shut down when I end the shell
       | 
       | 2: I want to configure my shares/mounts, which by default don't
       | go up from the .virtconfig dir
       | 
       | 3: I have to think about read only instances and multiple
       | instances of the vm
       | 
       | The idea is that when you later cd into a project directory,
       | .direnv (I think) can automatically turn into a Linux shell, or
       | other OS which is also sandboxed.
       | 
       | I'd also want a single command that spans a Linux instance with
       | the current director mounted (r or Re) to Linux. This way you get
       | some sandboxing when trying someone else's code
        
       | willmeyers wrote:
       | I'll take a look at lima, but I've had nothing but problems using
       | colima as a docker alternative on my macbook air m1. Could be
       | user incompetence, but always got issues of images failing to
       | pull and containers erroring out in mysterious ways.
        
       | amelius wrote:
       | Anyone knowing a good way to do the reverse? I.e., run MacOS on
       | Linux?
        
         | mil22 wrote:
         | You can use VMware Workstation Player and an unlocker like
         | Auto-Unlocker (https://github.com/paolo-projects/auto-unlocker)
         | to enable Mac OS as a guest. It works, but it's very slow
         | because the Mac guest runs without GPU acceleration.
        
       | nathants wrote:
       | at a certain point it may be less work to make linux macos like
       | than to make macos linux like.
        
         | pjmlp wrote:
         | That is the thing when people buy Apple, but actually want
         | GNU/Linux for the actual work.
        
       | [deleted]
        
       | sgt wrote:
       | I see that lima has an option to choose between qemu and vz. What
       | are the pros/cons to each? Is vz performance better?
       | 
       | Update: I edited the YAML file for the Lima VM and changed from
       | qemu to vz, also made sure the mount was using virtiofs.
       | 
       | Observations - on the surface, no performance difference but I
       | haven't really done much yet. I noticed that there is no longer a
       | qemu process running (obviously), and I see that /System/Library/
       | Frameworks/Virtualization.framework/Versions/A/XPCServices/com.ap
       | ple.Virtualization.VirtualMachine.xpc/Contents/MacOS/com.apple.Vi
       | rtualization.VirtualMachine is now running.
       | 
       | Having a look at
       | https://developer.apple.com/documentation/virtualization?lan...
       | for the documentation. It definitely looks like an interesting
       | and well built framework.
        
         | sgt wrote:
         | Strange - com.apple.Virtualization.VirtualMachine goes into
         | 400% CPU and the Ubuntu VM freezes. I've now reproduced it
         | twice. Not sure why this happens.
        
       | MuffinFlavored wrote:
       | https://github.com/search?q=repo%3Alima-vm%2Flima%20qemu&typ...
       | 
       | It's a wrapper that interfaces with QEMU in the background to
       | make things nicer/easier in case anybody was wondering
        
         | Scarbutt wrote:
         | so it's doing software virtualization?
        
           | kwk1 wrote:
           | Looks like it defaults to using `-accel hvf`, roughly
           | analogous to KVM, so no.
        
             | MuffinFlavored wrote:
             | hvf = hypervisor framework
             | 
             | lima now supports "macOS Virtualization.Framework"
             | 
             | https://zarinfam.medium.com/what-are-the-advantages-of-
             | the-n...
             | 
             | https://news.ycombinator.com/item?id=36184400
             | 
             | I guess it's better/different and not just roughly the same
             | thing wrapped in new packaging?
        
         | hatf0 wrote:
         | Would be cool if we see something come out that uses the Apple
         | native Virtualization.framework so you can use the nested
         | Rosetta extensions on M1. Dunno if that's been done yet.
        
           | filleduchaos wrote:
           | UTM uses either Virtualization.framework or QEMU depending on
           | what you specify.
        
           | stetrain wrote:
           | It is an option in Lima, I'm not sure if they handle setting
           | up Rosetta yet though:
           | 
           | https://github.com/lima-vm/lima/blob/master/docs/vmtype.md
        
             | hatf0 wrote:
             | Oh sick! According to some of their GitHub issues
             | (https://github.com/lima-vm/lima/issues/1202) they do setup
             | Rosetta. I'll have to check this out then!
        
       | antimatter15 wrote:
       | I've recently been enjoying OrbStack (https://orbstack.dev/),
       | which I've found easier to get started with than Lima, starts up
       | faster, and automatically mounts volumes so you can access things
       | from Finder
       | 
       | It's unfortunately not fully open source
        
         | smcleod wrote:
         | Orbstack is nice to use but it's not open source and who knows
         | what they're going to charge for it, once VC gets its dirty
         | hands in there you know it'll become expensive.
        
         | gyre007 wrote:
         | Big fan of OrbStack here, too.
        
         | ElCapitanMarkla wrote:
         | It is a really nice looking product but I wish they would set
         | down a firmer plan for how they are going to charge for it.
        
           | tomcam wrote:
           | That jumped right out at me too
        
           | haberman wrote:
           | This is a couple months old, but is a reasonably concrete
           | proposal:
           | https://twitter.com/OrbStack/status/1656326409995055104
        
           | jzelinskie wrote:
           | I honestly think this is a feature and not a bug. The FAQ
           | shows an attention to detail for the trade-offs of various
           | pricing models[0]. It's clear that Danny cares about
           | monetizing the project in a thoughtful way.
           | 
           | I moved away from Docker Desktop to colima for a couple years
           | and would not pay for Docker Desktop, but after a few weeks
           | of swapping back to OrbStack now that it's public beta, I can
           | definitely see myself paying. OrbStack just works and gets
           | out of the way.
           | 
           | [0]: https://docs.orbstack.dev/faq#free
        
       | kirbyfan64sos wrote:
       | I want to point out that Lima also works on Linux, and it's super
       | useful there for development scenarios where a container just
       | doesn't cut it.
        
       | n8henrie wrote:
       | As a novice, I was surprised how easy it was to get the basics
       | working with plain old libvirt (on my M1 at least).
        
       | gpsz wrote:
       | Also worth looking at UTM [1] which uses the apple virtualization
       | framework, while also being a simple frontend to QEMU.
       | 
       | [1] https://github.com/utmapp/UTM
        
         | ChrisLTD wrote:
         | This is what I've been using. Very nice app.
        
         | SpriglyElixir12 wrote:
         | Is there a way to persist volumes in UTM? I want a persistent
         | fedora vm but haven't been able to set it up.
        
           | codetrotter wrote:
           | Did you run the Fedora installer in the VM, or just boot from
           | live-CD?
        
           | LeoPanthera wrote:
           | Persistence is the default. Maybe you are just using the live
           | environment, instead of actually doing the install?
        
         | hamandcheese wrote:
         | I had a pretty bad experience with running a desktop in UTM.
         | The UTM app itself freezes a lot and has to be force quit, and
         | I think there are issues with the GPU acceleration.
         | 
         | Parallels was a night and day difference in both stability and
         | responsiveness of my desktop. And copy/paste Just Worked as
         | well. Definitely worth the $100/year subscription in my
         | opinion.
        
         | mrweasel wrote:
         | I really like UTM for VM that I just need to shell into. It's
         | not as complete as something like VirtualBox or VMware Fusion,
         | but it does what I need.
         | 
         | The only thing I'd like to have is some sort of background
         | daemon, so my VM don't stop if I accidentally close the UTM
         | window.
        
           | coldtea wrote:
           | Can't you run it on scren/tmux?
        
           | gpsz wrote:
           | Yeah, thats pretty much my usage with UTM as well. I run it
           | in console mode, hide all the windows, and then SSH into my
           | VM.
        
       | stetrain wrote:
       | Also worth checking out is Colima, which uses Lima to give you a
       | linux container environment without needing to install Docker
       | Desktop:
       | 
       | https://github.com/abiosoft/colima
        
         | zokier wrote:
         | There is also Finch (from AWS):
         | https://github.com/runfinch/finch
         | 
         | > Finch provides a simple client which is integrated with
         | nerdctl. For the core build/run/push/pull commands, Finch
         | depends upon nerdctl to handle the heavy lifting. It works with
         | containerd for container management, and with BuildKit to
         | handle Open Container Initiative (OCI) image builds. These
         | components are all pulled together and run within a virtual
         | machine managed by Lima.
        
         | aequitas wrote:
         | Can't agree more. I've been using Docker for Mac and Colima
         | alternately past few weeks on the same machine and the same
         | projects. The amount of times I needed to curse at Colima was
         | zero, while Docker for Mac sadly is still a poor experience.
         | Every now and then things just "don't work" and you need to
         | reset or even reboot.
        
         | belthesar wrote:
         | Borrowing this thread to add additional context, Rancher
         | Desktop on macOS also uses Lima to make VMs for running k8s (I
         | think it's actually k3s?) on your workstation. I've been
         | meaning to try out Colima, since, while nerdctl is pretty
         | functional and things work, sometimes dealing with the nuances
         | when I don't really need a real Kubernetes environment for most
         | of my dev tasks is more overhead than I'd like. That said, if
         | you do need a proper k8s environment on macOS, Rancher Desktop
         | does work quite well, and makes a lot of sense especially if
         | your shared k8s environments are managed by Rancher.
        
         | vicaya wrote:
         | colima pretty much solves dev experience for docker and k8s on
         | mac, esp. for apple silicons (m1/m2), where you can build
         | multi-arch containers with ease.
         | 
         | Some interesting caveats:
         | 
         | * By default, system packages don't persist, as the default
         | alpine distribution runs on tmpfs and doesn't have a overlay.
         | This is a reasonable default, as it keeps the default VM
         | storage small.
         | 
         | * If you want to have additional system packages, you can turn
         | on a ubuntu overlay that supports additional systemd services
         | just fine. Of course, storage would balloon to a few GBs from a
         | few hundred MBs.
         | 
         | Edit: typos.
         | 
         | BTW, the result of docker build is immediately available to the
         | k8s (k3s) cluster without any insecure registry and/or side
         | loading/caching steps, thanks to the seamless buildkit
         | integration.
        
           | deathanatos wrote:
           | One more caveat: mounts don't work:
           | https://github.com/abiosoft/colima/issues/503
           | 
           | One of our tools runs in Docker just to ensure that it gets
           | the right version of its dependencies, and that bug is a
           | pretty huge bug for us, for that tool, as it basically broke
           | things.
           | 
           | Still, we use colima; it is a decent workaround for the
           | "Docker on macOS" problem otherwise.
        
         | Pazzaz wrote:
         | Also mentioned in the original post.
        
         | nottorp wrote:
         | So this Lima is some sort of frontend for Docker then? That
         | would be important to mention.
        
           | lloeki wrote:
           | lima (linux on macos) is a VM management tool CLI frontend
           | which can use QEMU or Virtualization.framework as a backend,
           | colima (containers on linux on macos) is leveraging lima to
           | set up a linux vm to handle linux containers straight from
           | macos (including host-vm shares, port forwardong to the vm,
           | etc...)
           | 
           | If you want to draw some very coarse comparisons with big
           | names, lima is like VMware Fusion, colima is like the Docker
           | for Mac app.
           | 
           | colima kind of fills one of the use cases of docker-machine
           | which kind of died as this use case was handled by DfM and
           | the other use case (handling machines for swarm) was folded
           | into docker swarm and docker compose.
        
           | [deleted]
        
           | 0xbadcafebee wrote:
           | No, Lima just sets up a VM for you. Colima is a wrapper
           | around Lima that can configure a Docker daemon and context
           | for you. You still need the Docker CLI to use Docker.
        
           | chalst wrote:
           | My understanding is that Colima is based on such a front-end,
           | but Lima is not.
        
         | fithisux wrote:
         | love it.
        
         | dewey wrote:
         | Colima is great, compared to Podman it's a lot more of a drop-
         | in replacement for my use case. I've always had issues with
         | Podman volumes but with Colima it was as simple as uninstalling
         | Docker Desktop and running "colima start".
         | 
         | There's one issue I'm running into where it becomes
         | unresponsive after a while and "docker ps" hangs forever
         | though.
        
       | 727564797069706 wrote:
       | How does it compare to https://multipass.run/?
        
         | todotask wrote:
         | I found it's a struggle to backup VM where it's store in
         | private folders.
        
         | antod wrote:
         | Multipass for me suffered from a bunch of Macos networking bugs
         | when on managed Macs. Kernel panics and vms that you couldn't
         | connect to etc. UTM also suffered from these too. Apparently
         | some have been fixed by now though.
        
         | mirekrusin wrote:
         | Multipass is fantastic, very easy to use, great for local k8s
         | playgrounds and cases where docker doesn't fit (ie. tests that
         | change system clock etc) or simply to have linux box at hand.
        
           | robszumski wrote:
           | I just stumbled across multipass 2 days ago and it's been
           | great for our local dev environment with a script to
           | manipulate a bunch of things with multipass exec.
           | 
           | I just wish multiarch containers weren't such a pain to deal
           | with.
        
         | dakiol wrote:
         | Same question. I have been using multipass on my Mac (M1), and
         | so far so good. The current limitation of multipass is that it
         | only runs Ubuntu VMs. Also, setting up fixed IPs for multiple
         | VMs is a bit tricky (if possible at all, I don't remember right
         | now).
         | 
         | I have a bash script that uses multipass to setup a few VMs...
         | but still it feels "primitive" compared to what I was using
         | when I had an intel Mac (I was using Vagrant, but the Vagrant
         | experience on M1 is awful: I have tried it with VMWare and it's
         | not very stable in my experience).
        
           | whartung wrote:
           | With my limited use cases, I've found multipass to be really
           | comfortable. Was really easy to get into and make work. I'm
           | not passionate about Linux distros, so Ubuntu is fine for me.
        
       | AceJohnny2 wrote:
       | I want to amplify this:
       | 
       | > _why not use containers? [...]_
       | 
       | > _on Mac you need to run containers inside a Linux VM anyway, so
       | I'd rather use a VM directly and not introduce another
       | unnecessary layer_
       | 
       | I was long confused at how Docker functioned on macOS, until I
       | learned that it's "just" running a Linux VM within which it runs
       | the container images. There is no other magic happening to run a
       | (linux-assuming) container on macOS.
        
       | dmarinus wrote:
       | I've been searching for a live iso for Windows to use with lima
       | (wima, Windows VM on Mac).
        
         | itsrobforreal wrote:
         | https://developer.microsoft.com/en-us/windows/downloads/virt...
        
       | dirteater_ wrote:
       | Funny to see this on the front page the same morning that I
       | switched back to using a remote dev box.
       | 
       | Lima constantly has i/o issues (usually network hangs, local
       | connections within the VM). It's pretty rough to use when I need
       | to do docker in Lima.
        
         | espe wrote:
         | it's all sshfs.. afaik they're looking into changing that. i
         | don't have the i/o issues but always backup any files in the vm
         | as they tend to get lost at some point.
        
       | favourable wrote:
       | How do you pass files into/out of the VM? I know Virtualbox has
       | the Guest Additions software which is very handy. I also know of
       | things like the Spice Project[0]. Does Lima have its own
       | solution?
       | 
       | [0] https://www.spice-space.org
        
         | rawbot wrote:
         | The author said that it mounts MacOS home dir by default, so
         | that would mean you can pass files that way.
        
           | favourable wrote:
           | Oops, glossed over that
        
       | jamifsud wrote:
       | Anyone have good (preferably open source but not required) tools
       | for running MacVMs on a Mac? Would love a way to programmatically
       | control MacVMs (create new from image, start, stop, etc) as part
       | of our Mac build server setup. GitHub actions Mac CI minutes are
       | so expensive so we run our own setup and VM level isolation seems
       | to be the best way to keep the build processes from stepping on
       | each other.
        
         | mannyv wrote:
         | VirtualBox supports it, as does VMWare Player. There's a
         | VirtualBox build for Apple Silicon, which might do the right
         | thing.
        
           | stephenr wrote:
           | Vbox for Arm macs doesn't run Arm VMs: it emulates 32bit x86
           | hardware _extremely_ slowly.
        
         | halostatue wrote:
         | Eclectic Light has Viable:
         | https://eclecticlight.co/virtualisation-on-apple-silicon/
        
         | gurjeet wrote:
         | I've had a good experience using Tart. It checks all the boxes
         | you asked.
         | 
         | https://tart.run/
        
       ___________________________________________________________________
       (page generated 2023-07-10 23:00 UTC)