Table of Contents
In this article, we will see how to install Lima on macOS Using 9 Easy Steps. Lima is a free and open source utility to launch linux virtual machines with automatic file sharing and port forwarding (similar to WSL2), and containerd on macOS based systems. So basically, it is like installing containerd in macOS unofficially. While lima is mostly created for macOS systems but it can also be used on Linux based systems. The ultimate goal of lima is to promote use of containerd
with nerdctl
to Mac users. It is fairly easy to install and work with. Here we will see the steps to install Lima on macOS Monterey system using 9 easy steps.
How to Install Lima on macOS Using 9 Easy Steps
Also Read: How to Install yq command line tool on macOS(Monterey 12)
Step 1: Prerequisites
a) You should have a running macOS
system.
b) You should have access to install the packages in your system.
c) You should have brew
utility available in your system.
Step 2: Install Lima
To install lima in your macOS system, you need to use brew install lima
command as shown below. This will download and install the package along with all its dependencies.
cyberithub@lpros2d0531 ~ % brew install lima Running `brew update --auto-update`... ==> Downloading https://formulae.brew.sh/api/formula.jws.json ####################################################################### 100.0% ==> Downloading https://formulae.brew.sh/api/cask.jws.json ####################################################################### 100.0% ==> Fetching dependencies for lima: capstone, pcre2, gettext, glib, ca-certificates, gmp, libunistring, libidn2, libtasn1, nettle, p11-kit, openssl@1.1, libevent, libnghttp2, unbound, gnutls, jpeg-turbo, libpng, libslirp, libssh, libusb, lzo, ncurses, pixman, snappy, vde, lz4, xz, zstd, and qemu ==> Fetching capstone ==> Downloading https://ghcr.io/v2/homebrew/core/capstone/manifests/4.0.2 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/capstone/blobs/sha256:dda60f389b39dc6b777940428feccee4a0b50db91629d152a5e62a95c3915d38 ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:dda60f389b39dc6b777940428feccee4a0b50db91629d152a5e62a95c3915d38?se=2023-03-16T11%3A40%3A00Z&sig=2aV8MPg2ez6XCKoRsJHoT ######################################################################## 100.0% .......................................................
Step 3: Check Version
To check the currently installed limactl
utility version, you need to use limactl --version
command as shown below.
cyberithub@lpros2d0531 ~ % limactl --version limactl version 0.15.0
Step 4: Start VM
Now that lima is installed successfully, you can now create a default instance using limactl start
command as shown below. This will create a default
linux instance by pulling the latest ubuntu release using current configuration. It will run nerdctl
from inside the vm without installing it as a local utility.
cyberithub@lpros2d0531 ~ % limactl start ? Creating an instance "default" Proceed with the current configuration INFO[0012] Attempting to download the image from "https://cloud-images.ubuntu.com/releases/22.10/release-20230215/ubuntu-22.10-server-cloudimg-amd64.img" digest="sha256:5e5c68cb12002111032d46489afe8596de575869696a59d2608a1895ca2b1fe6" 697.56 MiB / 697.56 MiB [------------------------------] 100.00% 3.30 MiB/s INFO[0228] Downloaded the image from "https://cloud-images.ubuntu.com/releases/22.10/release-20230215/ubuntu-22.10-server-cloudimg-amd64.img" INFO[0235] Attempting to download the nerdctl archive from "https://github.com/containerd/nerdctl/releases/download/v1.2.1/nerdctl-full-1.2.1-linux-amd64.tar.gz" digest="sha256:e8a3e40d442c566ee494375a4c6753121da69d8d7c7837f50f65771742757b36c" 230.56 MiB / 230.56 MiB [------------------------------] 100.00% 3.04 MiB/s INFO[0314] Downloaded the nerdctl archive from "https://github.com/containerd/nerdctl/releases/download/v1.2.1/nerdctl-full-1.2.1-linux-amd64.tar.gz" INFO[0323] [hostagent] Starting QEMU (hint: to watch the boot progress, see "/Users/cyberithub/.lima/default/serial.log") INFO[0323] SSH Local Port: 60022 INFO[0323] [hostagent] Waiting for the essential requirement 1 of 5: "ssh" INFO[0333] [hostagent] Waiting for the essential requirement 1 of 5: "ssh" INFO[0344] [hostagent] Waiting for the essential requirement 1 of 5: "ssh" INFO[0344] [hostagent] The essential requirement 1 of 5 is satisfied INFO[0344] [hostagent] Waiting for the essential requirement 2 of 5: "user session ready for ssh" INFO[0345] [hostagent] The essential requirement 2 of 5 is satisfied INFO[0345] [hostagent] Waiting for the essential requirement 3 of 5: "sshfs binary to be installed" INFO[0369] [hostagent] The essential requirement 3 of 5 is satisfied INFO[0369] [hostagent] Waiting for the essential requirement 4 of 5: "/etc/fuse.conf (/etc/fuse3.conf) to contain \"user_allow_other\""" INFO[0369] [hostagent] The essential requirement 4 of 5 is satisfied INFO[0369] [hostagent] Waiting for the essential requirement 5 of 5: "the guest agent to be running" INFO[0369] [hostagent] The essential requirement 5 of 5 is satisfied INFO[0369] [hostagent] Mounting "/Users/cyberithub" on "/Users/cyberithub" INFO[0369] [hostagent] Mounting "/tmp/lima" on "/tmp/lima" INFO[0370] [hostagent] Waiting for the optional requirement 1 of 2: "systemd must be available" INFO[0370] [hostagent] Forwarding "/run/lima-guestagent.sock" (guest) to "/Users/cyberithub/.lima/default/ga.sock" (host) INFO[0369] [hostagent] The optional requirement 1 of 2 is satisfied INFO[0369] [hostagent] Not forwarding TCP 127.0.0.54:53 INFO[0369] [hostagent] Not forwarding TCP 127.0.0.53:53 INFO[0369] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed" INFO[0369] [hostagent] Not forwarding TCP [::]:22 INFO[0369] [hostagent] The optional requirement 2 of 2 is satisfied INFO[0369] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished" INFO[0391] [hostagent] The final requirement 1 of 1 is satisfied INFO[0391] READY. Run `lima` to open the shell
Step 5: Open Shell
After instance creation, you can enter into the instance by running lima
command as shown below. Then you can run uname -a
command to get more information about the instance. Finally you can exit the instance by running exit
command as shown below.
cyberithub@lpros2d0531 ~ % lima [cyberithub@lima-default:/Users/cyberithub$ uname -a Linux lima-default 5.19.0-31-generic #32-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 20 15:20:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux [cyberithub@lima-default:/Users/cyberithub$ exit logout
Step 6: List VMs
To check all the instances, you need to use limactl list
command as shown below. This will show the instance details such as instance name, running status, ssh port, vmtype, architecture type, number of cpus allocated, amount of memory allocated, amount of disk allocated and instance directory path.
cyberithub@lpros2d0531 ~ % limactl list
NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR
default Running 127.0.0.1:60022 qemu x86_64 4 4GiB 100GiB ~/.lima/default
Step 7: Stop VM
If you are looking to stop a running instance then you need to use limactl stop <instance_name>
syntax. For example, here we are stopping default
instance using limactl stop default
command as shown below.
cyberithub@lpros2d0531 ~ % limactl stop default INFO[0000] Sending SIGINT to hostagent process 98746 INFO[0000] Waiting for the host agent and the driver processes to shut down INFO[0000] [hostagent] Received SIGINT, shutting down the host agent INFO[0000] [hostagent] Shutting down the host agent INFO[0000] [hostagent] Stopping forwarding "/run/lima-guestagent.sock" (guest) to "/Users/m1063177/.lima/default/ga.sock" (host) INFO[0000] Unmounting "/Users/cyberithub" INFO[0000] [hostagent] "/tmp/lima" INFO[0000] [hostagent] Shutting down QEMU with ACPI INFO[0000] [hostagent] Sending QMP system_powerdown command INFO[0000] [hostagent] QEMU has exited
Step 8: Delete VM
You can also delete any VM by using limactl delete <instance_name>
syntax. Here we are deleting default instance by using limactl delete default
command as shown below.
cyberithub@lpros2d0531 ~ % limactl delete default INFO[0000] The qemu driver process seems already stopped INFO[0000] The host agent process seems already stopped INFO[0000] Removing *.pid *.sock under "/Users/cyberithub/.lima/default" INFO[0000] Removing "/Users/cyberithub/.lima/default/ha.sock" INFO[0000] Deleted "default" ("/Users/cyberithub/.lima/default")
Step 9: Uninstall Lima
Once you are done with Lima, you can choose to uninstall it from your macOS system by using brew uninstall lima
command as shown below.
cyberithub@lpros2d0531 ~ % brew uninstall lima ==> Downloading https://formulae.brew.sh/api/cask.jws.json ######################################################################## 100.0% ==> Downloading https://formulae.brew.sh/api/formula.jws.json ##0=# # Uninstalling /usr/local/Cellar/lima/0.15.0... (74 files, 129MB)